Sha256: 53f90899860e51c964c3494b36f88f4c2ca69770745b6fe19034e247e875b7fc

Contents?: true

Size: 789 Bytes

Versions: 6

Compression:

Stored size: 789 Bytes

Contents

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

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

6 entries across 6 versions & 1 rubygems

Version Path
hamster-0.2.5 spec/hamster/list/init_spec.rb
hamster-0.2.4 spec/hamster/list/init_spec.rb
hamster-0.2.3 spec/hamster/list/init_spec.rb
hamster-0.2.2 spec/hamster/list/init_spec.rb
hamster-0.2.1 spec/hamster/list/init_spec.rb
hamster-0.2.0 spec/hamster/list/init_spec.rb