Sha256: aa3cd8f9ee8b62795e26abc2d8dfc9e8fd4d3bedc7f7df05d5ab3f4a5b178411

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

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

require 'hamster/list'

describe Hamster::List do

  [:to_a, :entries].each do |method|

    describe "##{method}" do

      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.to_a }.should_not raise_error
        end

      end

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

        describe "on #{values.inspect}" do

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

          it "returns #{values.inspect}" do
            @result.should == values
          end

          it "works with splat" do
            array = *@list
            array.should == values
          end

          it "returns a mutable array" do
            @result.last.should_not == "The End"
            @result << "The End"
            @result.last.should == "The End"
          end

        end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.2.5 spec/hamster/list/to_a_spec.rb
hamster-0.2.4 spec/hamster/list/to_a_spec.rb
hamster-0.2.3 spec/hamster/list/to_a_spec.rb
hamster-0.2.2 spec/hamster/list/to_a_spec.rb