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

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

Instance Method Summary (collapse)

Constructor Details

- (HashIncludingMatcher) initialize(expected)

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

- (Object) ==(actual)



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

- (Object) description



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

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