Sha256: 5dd7f9af123e05aafe46bbbfdf6771053863ef2f7ecc97b4d76cb6bb196cfda9

Contents?: true

Size: 692 Bytes

Versions: 59

Compression:

Stored size: 692 Bytes

Contents

module RR
  module WildcardMatchers
    class HashIncluding
      attr_reader :expected_hash

      def initialize(expected_hash)
        @expected_hash = expected_hash.clone
      end

      def wildcard_match?(other)
        return true if self == other
        expected_hash.each_pair do |key, value|
          return false unless other.has_key?(key) && other[key] == expected_hash[key]
        end
        return true
      end

      def inspect
        "hash_including(#{expected_hash.inspect})"
      end

      def ==(other)
        return false unless other.is_a?(self.class)
        self.expected_hash == other.expected_hash
      end
      alias_method :eql?, :==
    end
  end
end

Version data entries

59 entries across 55 versions & 9 rubygems

Version Path
rr-1.0.1 lib/rr/wildcard_matchers/hash_including.rb
rr-1.0.0 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.11 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.10 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.9 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.8 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.7 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.6 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.5 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.4 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.2 lib/rr/wildcard_matchers/hash_including.rb
redinger-rr-0.10.3 lib/rr/wildcard_matchers/hash_including.rb
rr-0.10.0 lib/rr/wildcard_matchers/hash_including.rb
rr-0.7.1 lib/rr/wildcard_matchers/hash_including.rb
rr-0.8.1 lib/rr/wildcard_matchers/hash_including.rb
rr-0.6.0 lib/rr/wildcard_matchers/hash_including.rb
rr-0.8.0 lib/rr/wildcard_matchers/hash_including.rb
rr-0.7.0 lib/rr/wildcard_matchers/hash_including.rb
rr-0.9.0 lib/rr/wildcard_matchers/hash_including.rb