Class: Sbmt::Pact::Matchers::V4::EachKeyValue

Inherits:
Base
  • Object
show all
Defined in:
lib/sbmt/pact/matchers/v4/each_key_value.rb

Instance Attribute Summary

Attributes inherited from Base

#kind, #opts, #spec_version, #template

Instance Method Summary collapse

Methods inherited from Base

#as_basic

Constructor Details

#initialize(key_matchers, template) ⇒ EachKeyValue

Returns a new instance of EachKeyValue.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sbmt/pact/matchers/v4/each_key_value.rb', line 8

def initialize(key_matchers, template)
  raise MatcherInitializationError, "#{self.class}: #{template} should be a Hash" unless template.is_a?(Hash)
  raise MatcherInitializationError, "#{self.class}: #{key_matchers} should be an Array" unless key_matchers.is_a?(Array)
  raise MatcherInitializationError, "#{self.class}: #{key_matchers} should be instances of Sbmt::Pact::Matchers::Base" unless key_matchers.all?(Sbmt::Pact::Matchers::Base)

  super(
    spec_version: Sbmt::Pact::Matchers::PACT_SPEC_V4,
    kind: [
      EachKey.new(key_matchers, {}),
      EachValue.new([Sbmt::Pact::Matchers::V2::Type.new("")], {})
    ],
    template: template
  )

  @key_matchers = key_matchers
end

Instance Method Details

#as_pluginObject



25
26
27
# File 'lib/sbmt/pact/matchers/v4/each_key_value.rb', line 25

def as_plugin
  raise MatcherInitializationError, "#{self.class}: each-key-value is not supported in plugin syntax. Use each / each_key / each_value matchers instead"
end