Sha256: f31d3ff4bec374df95101ca8630ebe43b943cf320e8694589741cfb1a6631543

Contents?: true

Size: 663 Bytes

Versions: 7

Compression:

Stored size: 663 Bytes

Contents

module Matchers
  class HashTheSameAs
    def initialize(expected)
      @expected = expected
    end

    def matches?(actual)
      @actual = actual
      hash = {}
      hash[@expected] = :some_arbitrary_value
      hash[@actual] == :some_arbitrary_value
    end

    def failure_message
      "expected #{@actual} to hash the same as #{@expected}; they must be `eql?` and have the same `#hash` value"
    end

    def negative_failure_message
      "expected #{@actual} to hash differently than #{@expected}; they must not be `eql?` or have a differing `#hash` values"
    end
  end

  def hash_the_same_as(expected)
    HashTheSameAs.new(expected)
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
arel-1.0.1 spec/support/matchers/hash_the_same_as.rb
arel-1.0.0 spec/support/matchers/hash_the_same_as.rb
arel-1.0.0.rc1 spec/support/matchers/hash_the_same_as.rb
arel-compat-0.4.0 spec/support/matchers/hash_the_same_as.rb
arel-0.4.0 spec/support/matchers/hash_the_same_as.rb
arel-0.3.3 spec/support/matchers/hash_the_same_as.rb
arel-0.3.2 spec/support/matchers/hash_the_same_as.rb