Class: HttpStub::Models::HashWithValueMatchers

Inherits:
Hash
  • Object
show all
Defined in:
lib/http_stub/models/hash_with_value_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(stub_hash) ⇒ HashWithValueMatchers

Returns a new instance of HashWithValueMatchers.



6
7
8
# File 'lib/http_stub/models/hash_with_value_matchers.rb', line 6

def initialize(stub_hash)
  stub_hash.each_pair { |key, value| self[key] = HttpStub::Models::ValueMatcher.new(value) }
end

Instance Method Details

#match?(actual_hash) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/http_stub/models/hash_with_value_matchers.rb', line 10

def match?(actual_hash)
  !(self.find do |key_and_value_matcher|
    other_value = actual_hash[key_and_value_matcher[0]]
    !key_and_value_matcher[1].match?(other_value)
  end)
end