Sha256: a1231919940488dc94bbb13a9934b959ac742c2298b18f09c00264d752e3c464

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

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

require 'hamster/list'

describe Hamster::List do

  describe "#tails" do

    it "is lazy" do
      lambda { Hamster.stream { fail }.tails }.should_not raise_error
    end

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

      expected = expected.map { |x| Hamster.list(*x) }

      describe "on #{values.inspect}" do

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

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

        it "returns #{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/tails_spec.rb
hamster-0.2.6 spec/hamster/list/tails_spec.rb