Sha256: 00f20ad23ba838b6d1cbd779a2ce4addf0d411ea99efb61aba6b6b453f13ddf4

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

require "spec_helper"
require "hamster/list"

describe Hamster::List do
  describe "#compact" do
    it "is lazy" do
      -> { Hamster.stream { fail }.compact }.should_not raise_error
    end

    [
      [[], []],
      [["A"], ["A"]],
      [%w[A B C], %w[A B C]],
      [[nil], []],
      [[nil, "B"], ["B"]],
      [["A", nil], ["A"]],
      [[nil, nil], []],
      [["A", nil, "C"], %w[A C]],
      [[nil, "B", nil], ["B"]],
    ].each do |values, expected|
      context "on #{values.inspect}" do
        let(:list) { L[*values] }

        it "preserves the original" do
          list.compact
          list.should eql(L[*values])
        end

        it "returns #{expected.inspect}" do
          list.compact.should eql(L[*expected])
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/hamster-3.0.0/spec/lib/hamster/list/compact_spec.rb
hamster-3.0.0 spec/lib/hamster/list/compact_spec.rb
hamster-2.0.0 spec/lib/hamster/list/compact_spec.rb