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.


6
7
8
# File 'lib/webmock/matchers/hash_argument_matcher.rb', line 6

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

Class Method Details

.from_rspec_matcher(matcher) ⇒ Object


16
17
18
# File 'lib/webmock/matchers/hash_argument_matcher.rb', line 16

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

Instance Method Details

#==(_actual, &block) ⇒ Object


10
11
12
13
14
# File 'lib/webmock/matchers/hash_argument_matcher.rb', line 10

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