Sha256: b84d923e968f99dc5745b88e50ca5928a336f55568481682d958250a9d4380b8

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Sbmt
  module Pact
    module Matchers
      module V4
        class EachKeyValue < Sbmt::Pact::Matchers::Base
          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

          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
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sbmt-pact-0.12.2 lib/sbmt/pact/matchers/v4/each_key_value.rb
sbmt-pact-0.12.1 lib/sbmt/pact/matchers/v4/each_key_value.rb
sbmt-pact-0.12.0 lib/sbmt/pact/matchers/v4/each_key_value.rb