Sha256: b04abe0d11d784be005d796b38525d0d512b3efd0da14bb7f73926219ed09ff9

Contents?: true

Size: 980 Bytes

Versions: 7

Compression:

Stored size: 980 Bytes

Contents

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

require 'hamster/hash'

describe Hamster::Hash do

  describe "#delete" do

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

    describe "with an existing key" do

      before do
        @result = @original.delete("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.delete("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

7 entries across 7 versions & 1 rubygems

Version Path
hamster-0.2.5 spec/hamster/hash/delete_spec.rb
hamster-0.2.4 spec/hamster/hash/delete_spec.rb
hamster-0.2.3 spec/hamster/hash/delete_spec.rb
hamster-0.2.2 spec/hamster/hash/delete_spec.rb
hamster-0.2.1 spec/hamster/hash/delete_spec.rb
hamster-0.2.0 spec/hamster/hash/delete_spec.rb
hamster-0.1.23 spec/hamster/hash/delete_spec.rb