Class: Spec::Mocks::ArgumentMatchers::HashIncludingMatcher
- Defined in:
- lib/spec/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.
58 59 60 |
# File '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/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 |
#description ⇒ Object
71 72 73 |
# File 'lib/spec/mocks/argument_matchers.rb', line 71 def description "hash_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})" end |