Sha256: d28546bae76ae4144af03716e87e22188ce5fffa75824354ba0005401ef17f42

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

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

require 'hamster/set'

describe Hamster::Set do

  [:map, :collect].each do |method|

    describe "##{method}" do

      describe "when empty" do

        before do
          @original = Hamster.set
          @mapped = @original.send(method) {}
        end

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

      end

      describe "when not empty" do

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

        describe "with a block" do

          before do
            @mapped = @original.send(method) { |item| item.downcase }
          end

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

          it "returns a new set with the mapped values" do
            @mapped.should == Hamster.set("a", "b", "c")
          end

        end

        describe "with no block" do

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

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

        end

      end

    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hamster-0.2.5 spec/hamster/set/map_spec.rb
hamster-0.2.4 spec/hamster/set/map_spec.rb
hamster-0.2.3 spec/hamster/set/map_spec.rb
hamster-0.2.2 spec/hamster/set/map_spec.rb
hamster-0.2.1 spec/hamster/set/map_spec.rb
hamster-0.2.0 spec/hamster/set/map_spec.rb
hamster-0.1.23 spec/hamster/set/map_spec.rb
hamster-0.1.22 spec/hamster/set/map_spec.rb
hamster-0.1.21 spec/hamster/set/map_spec.rb
hamster-0.1.20 spec/hamster/set/map_spec.rb
hamster-0.1.19 spec/hamster/set/map_spec.rb
hamster-0.1.18 spec/hamster/set/map_spec.rb
hamster-0.1.17 spec/hamster/set/map_spec.rb
hamster-0.1.16 spec/hamster/set/map_spec.rb
hamster-0.1.15 spec/hamster/set/map_spec.rb