Sha256: 15ba441829070977f797ef186ac0653802a1add66c7595b1ddad35ac18538c14

Contents?: true

Size: 833 Bytes

Versions: 2

Compression:

Stored size: 833 Bytes

Contents

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

require 'hamster/list'

describe Hamster::List do

  [:head, :first].each do |method|

    describe "on a really big list" do

      before do
        @list = Hamster.interval(0, STACK_OVERFLOW_DEPTH)
      end

      it "doesn't run out of stack" do
        lambda { @list.filter(&:nil?).head }.should_not raise_error
      end

    end

    describe "##{method}" do

      [
        [[], nil],
        [["A"], "A"],
        [["A", "B", "C"], "A"],
      ].each do |values, expected|

        describe "on #{values.inspect}" do

          before do
            @list = Hamster.list(*values)
          end

          it "returns #{expected.inspect}" do
            @list.send(method).should == expected
          end

        end

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.2.7 spec/hamster/list/head_spec.rb
hamster-0.2.6 spec/hamster/list/head_spec.rb