Class: Crspec::Mock::ArgumentMatchers::HashExcluding

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

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HashExcluding

Returns a new instance of HashExcluding.



30
31
32
# File 'lib/crspec/mock/argument_matchers.rb', line 30

def initialize(expected)
  @expected = expected
end

Instance Method Details

#===(actual) ⇒ Object Also known as: ==



34
35
36
37
38
# File 'lib/crspec/mock/argument_matchers.rb', line 34

def ===(actual)
  return false unless actual.is_a?(Hash)

  @expected.none? { |k, v| actual.key?(k) && (v == actual[k] || v === actual[k]) }
end

#inspectObject



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

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