Class: Crspec::Mock::ArgumentMatchers::HashIncluding

Inherits:
Object
  • Object
show all
Defined in:
lib/crspec/mock/argument_matchers.rb

Instance Method Summary collapse

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

#inspectObject



26
# File 'lib/crspec/mock/argument_matchers.rb', line 26

def inspect = "hash_including(#{@expected.inspect})"