Class: Spec::Mocks::ArgumentMatchers::HashIncludingMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HashIncludingMatcher

Returns a new instance of HashIncludingMatcher.



58
59
60
# File 'lib/vendor/plugins/rspec/lib/spec/mocks/argument_matchers.rb', line 58

def initialize(expected)
  @expected = expected
end

Instance Method Details

#==(actual) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/vendor/plugins/rspec/lib/spec/mocks/argument_matchers.rb', line 62

def ==(actual)
  @expected.each do | key, value |
    return false unless actual.has_key?(key) && value == actual[key]
  end
  true
rescue NoMethodError => ex
  return false
end

#descriptionObject



71
72
73
# File 'lib/vendor/plugins/rspec/lib/spec/mocks/argument_matchers.rb', line 71

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