Sha256: e44782dc1b4daeecdda5592b884b45f1da39babe431e626c4268229402c72d4f

Contents?: true

Size: 828 Bytes

Versions: 2

Compression:

Stored size: 828 Bytes

Contents

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

require 'hamster/set'

describe Hamster::Set do

  describe "#compact" do

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

      describe "on #{values.inspect}" do

        before do
          @original = Hamster.set(*values)
          @result = @original.compact
        end

        it "preserves the original" do
          @original.should == Hamster.set(*values)
        end

        it "returns #{expected.inspect}" do
          @result.should == Hamster.set(*expected)
        end

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.2.7 spec/hamster/set/compact_spec.rb
hamster-0.2.6 spec/hamster/set/compact_spec.rb