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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @hash.empty?
end

#inspectObject



68
69
70
# File 'lib/flexmock/argument_matchers.rb', line 68

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