Sha256: f22bcad86258c24cb7145c158ca575b0437887e177cf7675289eb4426667a070

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Hamster::Hash do

  describe "#eql?" do

    it "is true for the same instance" do
      hash = Hamster::Hash.new
      hash.should eql(hash)
    end

    it "is true for two empty instances" do
      Hamster::Hash.new.should eql(Hamster::Hash.new)
    end

    it "is true for two instances with the same key/value pairs" do
      a = Hamster::Hash.new.put("a", "Aye").put("b", "Bee").put("c", "See")
      b = Hamster::Hash.new.put("a", "Aye").put("b", "Bee").put("c", "See")
      a.should eql(b)
    end

    it "is false for two instances with different key/value pairs" do
      a = Hamster::Hash.new.put("a", "Aye").put("b", "Bee").put("c", "See")
      b = Hamster::Hash.new.put("a", "Aye").put("b", "Bee").put("d", "Dee")
      a.should_not eql(b)
    end

    it "is false for two instances with different numbers of overlapping key/value pairs" do
      a = Hamster::Hash.new.put("a", "Aye").put("b", "Bee").put("c", "See")
      b = Hamster::Hash.new.put("a", "Aye").put("b", "Bee")
      a.should_not eql(b)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.1.8 spec/hamster/hash/eql_spec.rb
hamster-0.1.7 spec/hamster/hash/eql_spec.rb