Sha256: 29c25225f67d0f386a3ba0762cdbea2e8a56016675045f4be662706efc8eb03c

Contents?: true

Size: 980 Bytes

Versions: 8

Compression:

Stored size: 980 Bytes

Contents

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

require 'hamster/hash'

describe Hamster::Hash do

  describe "#remove" do

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

    describe "with an existing key" do

      before do
        @result = @original.remove("B")
      end

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

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

    end

    describe "with a non-existing key" do

      before do
        @result = @original.remove("D")
      end

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

      it "returns self" do
        @result.should equal(@original)
      end

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hamster-0.1.22 spec/hamster/hash/remove_spec.rb
hamster-0.1.21 spec/hamster/hash/remove_spec.rb
hamster-0.1.20 spec/hamster/hash/remove_spec.rb
hamster-0.1.19 spec/hamster/hash/remove_spec.rb
hamster-0.1.18 spec/hamster/hash/remove_spec.rb
hamster-0.1.17 spec/hamster/hash/remove_spec.rb
hamster-0.1.16 spec/hamster/hash/remove_spec.rb
hamster-0.1.15 spec/hamster/hash/remove_spec.rb