Sha256: aacda3f3da47069e903ffc65b4485ff362017ebaae2fd4fc2a8118c0bcd8f5f3

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

require "spec_helper"

require "hamster/experimental/mutable_set"

describe Hamster::MutableSet do

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

    describe "##{method}" do

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

      describe "with a unique value" do

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

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

        it "modifies the set to include the new value" do
          @set.should == Hamster.mutable_set("A", "B", "C", "D")
        end

      end

      describe "with a duplicate value" do

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

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

        it "returns self" do
          @result.should equal(@set)
        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/experimental/mutable_set/add_spec.rb