Sha256: 79c68f6eaa92ad969e40c2413e974fd71e8cfb1e42368193b6a15d8fe08180dd

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 KB

Contents

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

require 'hamster/set'

describe Hamster::Set do

  [:filter, :select, :find_all].each do |method|

    describe "##{method}" do

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

      describe "when everything matches" do

        before do
          @result = @original.send(method) { |item| true }
        end

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

      end

      describe "when only some things match" do

        describe "with a block" do

          before do
            @result = @original.send(method) { |item| item == "A" }
          end

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

          it "returns a set with the matching values" do
            @result.should == Hamster.set("A")
          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

12 entries across 12 versions & 1 rubygems

Version Path
hamster-0.3.6 spec/hamster/set/filter_spec.rb
hamster-0.3.5 spec/hamster/set/filter_spec.rb
hamster-0.3.4 spec/hamster/set/filter_spec.rb
hamster-0.3.3 spec/hamster/set/filter_spec.rb
hamster-0.3.2 spec/hamster/set/filter_spec.rb
hamster-0.3.1 spec/hamster/set/filter_spec.rb
hamster-0.3.0 spec/hamster/set/filter_spec.rb
hamster-0.2.13 spec/hamster/set/filter_spec.rb
hamster-0.2.12 spec/hamster/set/filter_spec.rb
hamster-0.2.11 spec/hamster/set/filter_spec.rb
hamster-0.2.9 spec/hamster/set/filter_spec.rb
hamster-0.2.8 spec/hamster/set/filter_spec.rb