Class: WebMock::Matchers::HashArgumentMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/webmock/matchers/hash_argument_matcher.rb

Overview

Direct Known Subclasses

HashExcludingMatcher, HashIncludingMatcher

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HashArgumentMatcher

Returns a new instance of HashArgumentMatcher.



8
9
10
# File 'lib/webmock/matchers/hash_argument_matcher.rb', line 8

def initialize(expected)
  @expected = Hash[WebMock::Util::HashKeysStringifier.stringify_keys!(expected, deep: true).sort]
end

Class Method Details

.from_rspec_matcher(matcher) ⇒ Object



18
19
20
# File 'lib/webmock/matchers/hash_argument_matcher.rb', line 18

def self.from_rspec_matcher(matcher)
  new(matcher.instance_variable_get(:@expected))
end

Instance Method Details

#==(_actual, &block) ⇒ Object



12
13
14
15
16
# File 'lib/webmock/matchers/hash_argument_matcher.rb', line 12

def ==(_actual, &block)
  @expected.all?(&block)
rescue NoMethodError
  false
end