Module: Cuprum::Rails::RSpec::Contracts::ActionContracts::ShouldRequireExistingEntityContract
- Extended by:
- RSpec::SleepingKingStudios::Contract
- Defined in:
- lib/cuprum/rails/rspec/contracts/action_contracts.rb
Overview
Contract asserting the action requires a valid entity.
Instance Method Summary collapse
-
#apply(example_group, **options) { ... } ⇒ Object
Adds the contract to the example group.
Instance Method Details
#apply(example_group, **options) { ... } ⇒ Object
Adds the contract to the example group.
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/cuprum/rails/rspec/contracts/action_contracts.rb', line 452 contract do |**, &block| describe '#call' do include Cuprum::Rails::RSpec::ContractHelpers context 'when the entity does not exist' do let(:request) do Cuprum::Rails::Request.new(params: configured_params) end let(:configured_primary_key_value) do option_with_default( [:primary_key_value], default: 0 ) end let(:configured_params) do option_with_default( [:params], default: {} ) .merge({ 'id' => configured_primary_key_value }) end let(:expected_error) do Cuprum::Collections::Errors::NotFound.new( attribute_name: configured_resource.primary_key.to_s, attribute_value: configured_primary_key_value, collection_name: configured_resource.name, primary_key: true ) end before(:example) do primary_key_name = configured_resource.primary_key resource .entity_class .where(primary_key_name => configured_primary_key_value) .destroy_all end it 'should return a failing result' do expect(call_action) .to be_a_failing_result .with_error(expected_error) end instance_exec(&block) if block end end end |