Sha256: df3920fed506ce7609de91719f8bd3bb371e551a334ddd7e9b306d6364453a7a

Contents?: true

Size: 1017 Bytes

Versions: 8

Compression:

Stored size: 1017 Bytes

Contents

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

require 'hamster/set'

describe Hamster::Set do

  [:find, :detect].each do |method|

    describe "##{method}" do

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

        describe "on #{values.inspect}" do

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

          describe "with a block" do

            it "returns #{expected.inspect}" do
              @set.send(method) { |x| x == item }.should == expected
            end

          end

          describe "without a block" do

            it "returns nil" do
              @set.send(method).should be_nil
            end

          end

        end

      end

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hamster-0.2.5 spec/hamster/set/find_spec.rb
hamster-0.2.4 spec/hamster/set/find_spec.rb
hamster-0.2.3 spec/hamster/set/find_spec.rb
hamster-0.2.2 spec/hamster/set/find_spec.rb
hamster-0.2.1 spec/hamster/set/find_spec.rb
hamster-0.2.0 spec/hamster/set/find_spec.rb
hamster-0.1.23 spec/hamster/set/find_spec.rb
hamster-0.1.22 spec/hamster/set/find_spec.rb