Module: RSpec::Support::FuzzyMatcher
- Defined in:
- lib/rspec/support/fuzzy_matcher.rb
Overview
Provides a means to fuzzy-match between two arbitrary objects. Understands array/hash nesting. Uses ‘===` or `==` to perform the matching.
Class Method Summary collapse
Class Method Details
.values_match?(expected, actual) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rspec/support/fuzzy_matcher.rb', line 8 def self.values_match?(expected, actual) if Hash === actual return hashes_match?(expected, actual) if Hash === expected elsif Array === expected && Enumerable === actual && !(Struct === actual) return arrays_match?(expected, actual.to_a) end return true if expected == actual begin expected === actual rescue ArgumentError # Some objects, like 0-arg lambdas on 1.9+, raise # ArgumentError for `expected === actual`. false end end |