Sha256: 03cef6703c4d0f9cfbb774b78cf30d7149381929a64cb2c2084ca21f7d4d1b45

Contents?: true

Size: 861 Bytes

Versions: 6

Compression:

Stored size: 861 Bytes

Contents

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

require 'hamster/list'

describe Hamster::List do

  describe "#drop" do

    it "is lazy" do
      lambda { Hamster.stream { fail }.drop(1) }.should_not raise_error
    end

    [
      [[], 10, []],
      [["A"], 10, []],
      [["A"], -1, ["A"]],
      [["A", "B", "C"], 0, ["A", "B", "C"]],
      [["A", "B", "C"], 2, ["C"]],
    ].each do |values, number, expected|

      describe "#{number} from #{values.inspect}" do

        before do
          @original = Hamster.list(*values)
          @result = @original.drop(number)
        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/drop_spec.rb
hamster-0.2.4 spec/hamster/list/drop_spec.rb
hamster-0.2.3 spec/hamster/list/drop_spec.rb
hamster-0.2.2 spec/hamster/list/drop_spec.rb
hamster-0.2.1 spec/hamster/list/drop_spec.rb
hamster-0.2.0 spec/hamster/list/drop_spec.rb