class RR::WildcardMatchers::HashIncluding

Attributes

expected_hash[R]

Public Class Methods

new(expected_hash) click to toggle source
# File lib/rr/wildcard_matchers/hash_including.rb, line 6
def initialize(expected_hash)
  @expected_hash = expected_hash.dup
end

Public Instance Methods

==(other) click to toggle source
# File lib/rr/wildcard_matchers/hash_including.rb, line 19
def ==(other)
  other.is_a?(self.class) &&
  other.expected_hash == self.expected_hash
end
Also aliased as: eql?
eql?(other)
Alias for: ==
inspect() click to toggle source
# File lib/rr/wildcard_matchers/hash_including.rb, line 25
def inspect
  "hash_including(#{expected_hash.inspect})"
end
wildcard_match?(other) click to toggle source
# File lib/rr/wildcard_matchers/hash_including.rb, line 10
def wildcard_match?(other)
  self == other || (
    other.is_a?(Hash) &&
    expected_hash.all? { |k, v|
      other.key?(k) && other[k] == expected_hash[k]
    }
  )
end