Class: FlexMock::HashMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/flexmock/argument_matchers.rb

Overview

Match hashes that match all the fields of hash.

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HashMatcher

Returns a new instance of HashMatcher.



59
60
61
# File 'lib/flexmock/argument_matchers.rb', line 59

def initialize(hash)
  @hash = hash
end

Instance Method Details

#===(target) ⇒ Object



62
63
64
# File 'lib/flexmock/argument_matchers.rb', line 62

def ===(target)
  @hash.all? { |k, v| target[k] == v }
end

#inspectObject



65
66
67
# File 'lib/flexmock/argument_matchers.rb', line 65

def inspect
  "hsh(#{@hash.inspect})"
end