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

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb

Direct Known Subclasses

HashExcludingMatcher, HashIncludingMatcher

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ BaseHashMatcher

Returns a new instance of BaseHashMatcher.



179
180
181
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb', line 179

def initialize(expected)
  @expected = expected
end

Instance Method Details

#===(predicate, actual) ⇒ Object



183
184
185
186
187
188
189
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb', line 183

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

#description(name) ⇒ Object



191
192
193
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/argument_matchers.rb', line 191

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