Sha256: 03c4b8bd5f3cd6a36daecfad33eff7412721bbd95fa42dc4712a935b11dee428

Contents?: true

Size: 1.26 KB

Versions: 12

Compression:

Stored size: 1.26 KB

Contents

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

require 'set'
require 'hamster/set'

describe Hamster::Set do

  [:eql?, :==].each do |method|

    describe "##{method}" do

      describe "returns false when comparing with" do

        before do
          @set = Hamster.set("A", "B", "C")
        end

        it "a standard set" do
          @set.send(method, Set["A", "B", "C"]).should == false
        end

        it "an aribtrary object" do
          @set.send(method, Object.new).should == false
        end

      end

      [
        [[], [], true],
        [[], [nil], false],
        [["A"], [], false],
        [["A"], ["A"], true],
        [["A"], ["B"], false],
        [["A", "B"], ["A"], false],
        [["A", "B", "C"], ["A", "B", "C"], true],
        [["C", "A", "B"], ["A", "B", "C"], true],
      ].each do |a, b, expected|

        describe "returns #{expected.inspect}" do

          before do
            @a = Hamster.set(*a)
            @b = Hamster.set(*b)
          end

          it "for #{a.inspect} and #{b.inspect}" do
            @a.send(method, @b).should == expected
          end

          it "for #{b.inspect} and #{a.inspect}" do
            @b.send(method, @a).should == expected
          end

        end

      end

    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hamster-0.3.6 spec/hamster/set/eql_spec.rb
hamster-0.3.5 spec/hamster/set/eql_spec.rb
hamster-0.3.4 spec/hamster/set/eql_spec.rb
hamster-0.3.3 spec/hamster/set/eql_spec.rb
hamster-0.3.2 spec/hamster/set/eql_spec.rb
hamster-0.3.1 spec/hamster/set/eql_spec.rb
hamster-0.3.0 spec/hamster/set/eql_spec.rb
hamster-0.2.13 spec/hamster/set/eql_spec.rb
hamster-0.2.12 spec/hamster/set/eql_spec.rb
hamster-0.2.11 spec/hamster/set/eql_spec.rb
hamster-0.2.9 spec/hamster/set/eql_spec.rb
hamster-0.2.8 spec/hamster/set/eql_spec.rb