Sha256: 9ce50d57ad8132edf3d40f7d90780c4d3cca63fa97dc23df53f886dc59da46fb

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

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

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

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.2.7 spec/hamster/set/add_spec.rb
hamster-0.2.6 spec/hamster/set/add_spec.rb