Sha256: b7f5daaf4599818a0e8eaefd23e82027f2be0fbc0f4f161b681ca258215f9599

Contents?: true

Size: 728 Bytes

Versions: 1

Compression:

Stored size: 728 Bytes

Contents

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

describe Hamster::Set do

  describe "#each" do

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

    describe "with a block (internal iteration)" do

      it "returns self" do
        @set.each {}.should equal(@set)
      end

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

    end

    describe "with no block (external iteration)" do

      it "returns an enumerator over all key value pairs" do
        Set[*@set.each.to_a.flatten].should == Set["A", "B", "C"]
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-0.1.11 spec/hamster/set/each_spec.rb