Class: RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HashIncludingMatcher

Returns a new instance of HashIncludingMatcher.



55
56
57
# File 'lib/rspec/mocks/argument_matchers.rb', line 55

def initialize(expected)
  @expected = expected
end

Instance Method Details

#==(actual) ⇒ Object



59
60
61
62
63
# File 'lib/rspec/mocks/argument_matchers.rb', line 59

def ==(actual)
  @expected.all? {|k,v| actual.has_key?(k) && v == actual[k]}
rescue NoMethodError
  false
end

#descriptionObject



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

def description
  "hash_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})"
end