Sha256: 7f77a6375aa8665d7887dee4b1abc4c78af4ec11d81a3c3f9c7bfc8aac0ac9f8

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

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

require 'set'
require 'hamster/set'

describe Hamster::Set do

  [:each, :foreach].each do |method|

    describe "##{method}" do

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

      describe "with a block (internal iteration)" do

        it "returns nil" do
          @set.send(method) {}.should be_nil
        end

        it "yields all values" do
          actual_values = Set[]
          @set.send(method) { |value| actual_values << value }
          actual_values.should == Set["A", "B", "C"]
        end

      end

      describe "with no block" do

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

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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