Module: Cuprum::Rails::RSpec::Contracts::Actions::UpdateContracts

Defined in:
lib/cuprum/rails/rspec/contracts/actions/update_contracts.rb

Overview

Namespace for RSpec update contracts, which validate update implementations.

Defined Under Namespace

Modules: ShouldBeAnUpdateActionContract, ShouldUpdateTheEntityContract

Class Method Summary collapse

Class Method Details

.parameters(context:, resource:, **options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cuprum/rails/rspec/contracts/actions/update_contracts.rb', line 13

def self.parameters(context:, resource:, **options) # rubocop:disable Metrics/MethodLength
  attributes    =
    Cuprum::Rails::RSpec::ContractHelpers.option_with_default(
      options[:valid_attributes],
      context: context
    )
  entity        =
    Cuprum::Rails::RSpec::ContractHelpers.option_with_default(
      options[:existing_entity],
      context: context
    )
  resource_name = resource.singular_name

  Cuprum::Rails::RSpec::ContractHelpers.option_with_default(
    options[:params],
    context: context,
    default: {
      'id'          => entity[resource.primary_key],
      resource_name => attributes
    }
  )
end