Sha256: 51c41385e2ec5e4f45a84284f8a69e5c9e1844d51221250f323ba19bd43ba319

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

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

require 'hamster/hash'

describe Hamster::Hash do

  [:put, :[]=].each do |method|

    describe "##{method}" do

      before do
        @original = Hamster.hash("A" => "aye", "B" => "bee", "C" => "see")
      end

      describe "with a unique key" do

        before do
          @result = @original.send(method, "D", "dee")
        end

        it "preserves the original" do
          @original.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "see")
        end

        it "returns a copy with the superset of key/value pairs" do
          @result.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "see", "D" => "dee")
        end

      end

      describe "with a duplicate key" do

        before do
          @result = @original.send(method, "C", "sea")
        end

        it "preserves the original" do
          @original.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "see")
        end

        it "returns a copy with the superset of key/value pairs" do
          @result.should == Hamster.hash("A" => "aye", "B" => "bee", "C" => "sea")
        end

      end

    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hamster-0.2.5 spec/hamster/hash/put_spec.rb
hamster-0.2.4 spec/hamster/hash/put_spec.rb
hamster-0.2.3 spec/hamster/hash/put_spec.rb
hamster-0.2.2 spec/hamster/hash/put_spec.rb
hamster-0.2.1 spec/hamster/hash/put_spec.rb
hamster-0.2.0 spec/hamster/hash/put_spec.rb
hamster-0.1.23 spec/hamster/hash/put_spec.rb
hamster-0.1.22 spec/hamster/hash/put_spec.rb
hamster-0.1.21 spec/hamster/hash/put_spec.rb
hamster-0.1.20 spec/hamster/hash/put_spec.rb
hamster-0.1.19 spec/hamster/hash/put_spec.rb
hamster-0.1.18 spec/hamster/hash/put_spec.rb
hamster-0.1.17 spec/hamster/hash/put_spec.rb
hamster-0.1.16 spec/hamster/hash/put_spec.rb
hamster-0.1.15 spec/hamster/hash/put_spec.rb