Sha256: d9e9cbdd4eefa327e581fc54d7f1812ea9a68c96457566f22e7b82d3a45947bd

Contents?: true

Size: 907 Bytes

Versions: 12

Compression:

Stored size: 907 Bytes

Contents

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

require 'hamster/set'

describe Hamster::Set do

  [:intersection, :intersect, :&].each do |method|

    describe "##{method}" do

      [
        [[], [], []],
        [["A"], [], []],
        [["A"], ["A"], ["A"]],
        [["A", "B", "C"], ["B"], ["B"]],
        [["A", "B", "C"], ["A", "C"], ["A", "C"]],
      ].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
            @result = @a.send(method, @b)
          end

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

          after  do
            @result.should == Hamster.set(*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/intersection_spec.rb
hamster-0.3.5 spec/hamster/set/intersection_spec.rb
hamster-0.3.4 spec/hamster/set/intersection_spec.rb
hamster-0.3.3 spec/hamster/set/intersection_spec.rb
hamster-0.3.2 spec/hamster/set/intersection_spec.rb
hamster-0.3.1 spec/hamster/set/intersection_spec.rb
hamster-0.3.0 spec/hamster/set/intersection_spec.rb
hamster-0.2.13 spec/hamster/set/intersection_spec.rb
hamster-0.2.12 spec/hamster/set/intersection_spec.rb
hamster-0.2.11 spec/hamster/set/intersection_spec.rb
hamster-0.2.9 spec/hamster/set/intersection_spec.rb
hamster-0.2.8 spec/hamster/set/intersection_spec.rb