Class: Pact::Matchers::V4::EachKey
- Defined in:
- lib/pact/matchers/v4/each_key.rb
Instance Attribute Summary
Attributes inherited from Base
#kind, #opts, #spec_version, #template
Instance Method Summary collapse
- #as_plugin ⇒ Object
-
#initialize(key_matchers, template) ⇒ EachKey
constructor
A new instance of EachKey.
Methods inherited from Base
Constructor Details
#initialize(key_matchers, template) ⇒ EachKey
Returns a new instance of EachKey.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pact/matchers/v4/each_key.rb', line 7 def initialize(key_matchers, template) raise MatcherInitializationError, "#{self.class}: #{template} should be a Hash" unless template.is_a?(Hash) unless key_matchers.is_a?(Array) raise MatcherInitializationError, "#{self.class}: #{key_matchers} should be an Array" end unless key_matchers.all?(Pact::Matchers::Base) raise MatcherInitializationError, "#{self.class}: #{key_matchers} should be instances of Pact::Matchers::Base" end unless key_matchers.size > 0 raise MatcherInitializationError, "#{self.class}: #{key_matchers} size should be greater than 0" end super(spec_version: Pact::Matchers::PACT_SPEC_V4, kind: 'each-key', template: template, opts: { rules: key_matchers }) # rubocop:disable Layout/LineLength end |
Instance Method Details
#as_plugin ⇒ Object
26 27 28 29 30 |
# File 'lib/pact/matchers/v4/each_key.rb', line 26 def as_plugin @opts[:rules].map do |matcher| "eachKey(#{matcher.as_plugin})" end.join(', ') end |