Sha256: 8cb768066a1034ab24b10226d4c071f6e97332ae8b11af675e79a21e42ed4853

Contents?: true

Size: 961 Bytes

Versions: 4

Compression:

Stored size: 961 Bytes

Contents

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

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

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.1.14 spec/hamster/set/add_spec.rb
hamster-0.1.13 spec/hamster/set/add_spec.rb
hamster-0.1.12 spec/hamster/set/add_spec.rb
hamster-0.1.11 spec/hamster/set/add_spec.rb