Sha256: 7269db6f0fd8acdd2a622b081ad40298d7406e40fe4fc0c19c1eb7005daad022

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

require "spec_helper"

require "hamster/list"

describe Hamster::List do

  [:uniq, :nub, :remove_duplicates].each do |method|

    describe "##{method}" do

      it "is lazy" do
        -> { Hamster.stream { fail }.uniq }.should_not raise_error
      end

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

        describe "on #{values.inspect}" do

          before do
            @original = Hamster.list(*values)
            @result = @original.send(method)
          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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-1.0.1.pre.rc.1 spec/hamster/list/uniq_spec.rb