Sha256: ccd70207770c4e428ac76fd1d49394123834961a7b94cb0038c91f913d1c6928

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 Bytes

Contents

require File.expand_path('../../../spec_helper', __FILE__)

require 'hamster/hash'

describe Hamster::Hash do

  describe "#hash" do

    describe "on an empty hash" do

      before do
        @result = Hamster.hash.hash
      end

      it "returns 0" do
        @result.should == 0
      end

    end

    describe "on a non-empty hash" do

      class Item

        attr_reader :hash

        def initialize(h)
          @hash = h
        end

      end

      before do
        hash = Hamster.hash(Item.new(19) => "A", Item.new(31) => "B", Item.new(107) => "C")
        @result = hash.hash
      end

      it "returns XOR of each item's hash" do
        @result.should == 103
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hamster-0.3.1 spec/hamster/hash/hash_spec.rb
hamster-0.3.0 spec/hamster/hash/hash_spec.rb
hamster-0.2.13 spec/hamster/hash/hash_spec.rb