Module: Cuprum::Rails::RSpec::Contracts::ActionContracts::ShouldRequirePrimaryKeyContract
- Extended by:
- RSpec::SleepingKingStudios::Contract
- Defined in:
- lib/cuprum/rails/rspec/contracts/action_contracts.rb
Overview
Contract asserting the action requires a primary key.
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.
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'lib/cuprum/rails/rspec/contracts/action_contracts.rb', line 600 contract do |**, &block| describe '#call' do include Cuprum::Rails::RSpec::ContractHelpers context 'when the parameters do not include a primary key' do let(:request) do Cuprum::Rails::Request.new(params: configured_params) end let(:configured_params) do option_with_default([:params], default: {}) .dup .tap { |hsh| hsh.delete('id') } end let(:configured_expected_error) do errors = Stannum::Errors.new.tap do |err| err['id'].add(Stannum::Constraints::Presence::TYPE) end Cuprum::Rails::Errors::InvalidParameters.new(errors: errors) end it 'should return a failing result' do expect(call_action) .to be_a_failing_result .with_error(configured_expected_error) end instance_exec(&block) if block end end end |