Sha256: e1f8ed7d80a3104214c0ba104123ef6144d821757cadeea53777593637648c06

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 Bytes

Contents

require "spec_helper"
require "hamster/vector"

describe Hamster::Vector do

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

    describe "##{method}" do

      describe "with no block" do

        before do
          @vector = Hamster.vector("A", "B", "C")
          @result = @vector.send(method)
        end

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

      end

      describe "with a block" do

        before do
          @vector = Hamster.vector(*(1..1025))
          @items = []
          @result = @vector.send(method) { |item| @items << item }
        end

        it "returns nil" do
          @result.should be_nil
        end

        it "iterates over the items in order" do
          @items.should == (1..1025).to_a
        end

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-1.0.1.pre.rc.1 spec/hamster/vector/each_spec.rb