Sha256: e7bd3677754a4e7f17167788e292f73b0042d3080bc5b5a8c45810ee01dfa52a

Contents?: true

Size: 681 Bytes

Versions: 3

Compression:

Stored size: 681 Bytes

Contents

require "spec_helper"
require "hamster/set"

describe Hamster::Set do
  describe "#compact" do
    [
      [[], []],
      [["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|
      describe "on #{values.inspect}" do
        let(:set) { S[*values] }

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

        it "returns #{expected.inspect}" do
          set.compact.should eql(S[*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/set/compact_spec.rb
hamster-3.0.0 spec/lib/hamster/set/compact_spec.rb
hamster-2.0.0 spec/lib/hamster/set/compact_spec.rb