Sha256: 5edcc690c168400f8776d48f2429d72e41ed5fd01f3b005955fc4b2f05a451c8

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

require "spec_helper"

require "hamster/set"

describe Hamster::Set do

  [:add, :<<].each do |method|

    describe "##{method}" do

      before do
        @original = Hamster.set("A", "B", "C")
      end

      describe "with a unique value" do

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

        it "preserves the original" do
          @original.should == Hamster.set("A", "B", "C")
        end

        it "returns a copy with the superset of values" do
          @result.should == Hamster.set("A", "B", "C", "D")
        end

      end

      describe "with a duplicate value" do

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

        it "preserves the original values" do
          @original.should == Hamster.set("A", "B", "C")
        end

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

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-1.0.1.pre.rc.1 spec/hamster/set/add_spec.rb