Class: RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher

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

Instance Method Summary (collapse)

Constructor Details

- (HashExcludingMatcher) initialize(expected)

A new instance of HashExcludingMatcher

71
72
73
# File 'lib/rspec/mocks/argument_matchers.rb', line 71
def initialize(expected)
  @expected = expected
end

Instance Method Details

- (Object) ==(actual)

75
76
77
78
79
# File 'lib/rspec/mocks/argument_matchers.rb', line 75
def ==(actual)
  @expected.none? {|k,v| actual.has_key?(k) && v == actual[k]}
rescue NoMethodError
  false
end

- (Object) description

81
82
83
# File 'lib/rspec/mocks/argument_matchers.rb', line 81
def description
  "hash_not_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})"
end