Class: RSpec::Mocks::ArgumentMatchers::BaseHashMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/mocks/argument_matchers.rb

Direct Known Subclasses

HashExcludingMatcher, HashIncludingMatcher

Instance Method Summary (collapse)

Constructor Details

- (BaseHashMatcher) initialize(expected)

Returns a new instance of BaseHashMatcher



163
164
165
# File 'lib/rspec/mocks/argument_matchers.rb', line 163

def initialize(expected)
  @expected = expected
end

Instance Method Details

- (Object) ===(predicate, actual)



167
168
169
170
171
172
173
# File 'lib/rspec/mocks/argument_matchers.rb', line 167

def ===(predicate, actual)
  @expected.__send__(predicate) do |k, v|
    actual.has_key?(k) && Support::FuzzyMatcher.values_match?(v, actual[k])
  end
rescue NoMethodError
  false
end

- (Object) description(name)



175
176
177
# File 'lib/rspec/mocks/argument_matchers.rb', line 175

def description(name)
  "#{name}(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})"
end