Sha256: f418290a12b3e8756d1f6fa18e9cc172c94b2e4f72abfdf6b861d2c4573cb4b1

Contents?: true

Size: 787 Bytes

Versions: 2

Compression:

Stored size: 787 Bytes

Contents

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

require 'hamster/list'

describe Hamster::List do

  describe "#init" do

    it "is lazy" do
      lambda { Hamster.stream { false }.init }.should_not raise_error
    end

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

      describe "on #{values.inspect}" do

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

        it "preserves the original" do
          @original.should == Hamster.list(*values)
        end

        it "returns the list without the last element: #{expected.inspect}" do
          @result.should == Hamster.list(*expected)
        end

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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