Class: RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
- Inherits:
-
Object
- Object
- RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
- Defined in:
- lib/rspec/mocks/argument_matchers.rb
Instance Method Summary collapse
- #==(actual) ⇒ Object
- #description ⇒ Object
-
#initialize(expected) ⇒ HashIncludingMatcher
constructor
A new instance of HashIncludingMatcher.
Constructor Details
#initialize(expected) ⇒ HashIncludingMatcher
Returns a new instance of HashIncludingMatcher.
54 55 56 |
# File 'lib/rspec/mocks/argument_matchers.rb', line 54 def initialize(expected) @expected = expected end |
Instance Method Details
#==(actual) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/rspec/mocks/argument_matchers.rb', line 58 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 |
#description ⇒ Object
67 68 69 |
# File 'lib/rspec/mocks/argument_matchers.rb', line 67 def description "hash_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})" end |