Module: Cuprum::Rails::RSpec::Contracts::ActionContracts::ShouldFindTheEntityContract
- Extended by:
- RSpec::SleepingKingStudios::Contract
- Defined in:
- lib/cuprum/rails/rspec/contracts/action_contracts.rb
Overview
Contract asserting the action finds and returns the requested entity.
Instance Method Summary collapse
-
#apply(example_group, existing_entity: , **options) { ... } ⇒ Object
Adds the contract to the example group.
Instance Method Details
#apply(example_group, existing_entity: , **options) { ... } ⇒ Object
Adds the contract to the example group.
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/cuprum/rails/rspec/contracts/action_contracts.rb', line 394 contract do |existing_entity:, **, &block| describe '#call' do include Cuprum::Rails::RSpec::ContractHelpers context 'when the entity exists' do let(:request) do Cuprum::Rails::Request.new(params: configured_params) end let(:configured_existing_entity) do option_with_default(existing_entity) end let(:configured_params) do resource_id = configured_existing_entity[configured_resource.primary_key] option_with_default( [:params], default: { 'id' => resource_id } ) end let(:configured_expected_value) do resource_name = configured_resource.singular_name option_with_default( [:expected_value], default: { resource_name => configured_existing_entity } ) end it 'should return a passing result' do expect(call_action) .to be_a_passing_result .with_value(configured_expected_value) end instance_exec(&block) if block end end end |