Sha256: 586c23d34cc180935ef2430fe312c4b72f441804224777bb53e4da9e8ed50898

Contents?: true

Size: 853 Bytes

Versions: 6

Compression:

Stored size: 853 Bytes

Contents

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

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

6 entries across 6 versions & 1 rubygems

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