Class: Crspec::Mock::ArgumentMatchers::HashIncluding
- Inherits:
-
Object
- Object
- Crspec::Mock::ArgumentMatchers::HashIncluding
- Defined in:
- lib/crspec/mock/argument_matchers.rb
Instance Method Summary collapse
- #===(actual) ⇒ Object (also: #==)
-
#initialize(expected) ⇒ HashIncluding
constructor
A new instance of HashIncluding.
- #inspect ⇒ Object
Constructor Details
#initialize(expected) ⇒ HashIncluding
Returns a new instance of HashIncluding.
15 16 17 |
# File 'lib/crspec/mock/argument_matchers.rb', line 15 def initialize(expected) @expected = expected end |
Instance Method Details
#===(actual) ⇒ Object Also known as: ==
19 20 21 22 23 |
# File 'lib/crspec/mock/argument_matchers.rb', line 19 def ===(actual) return false unless actual.is_a?(Hash) @expected.all? { |k, v| actual.key?(k) && (v == actual[k] || v === actual[k]) } end |
#inspect ⇒ Object
26 |
# File 'lib/crspec/mock/argument_matchers.rb', line 26 def inspect = "hash_including(#{@expected.inspect})" |