<commit_before>require "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 an Enumerator" do
              @set.send(method).class.should be(Enumerator)
            end
          end
        end
      end
    end
  end
end<commit_msg>Updated style of Set#find spec, made a test stricter<commit_after>require "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
          context "with a block" do
            it "returns #{expected.inspect}" do
              Hamster.set(*values).send(method) { |x| x == item }.should == expected
            end
          end

          context "without a block" do
            it "returns an Enumerator" do
              result = Hamster.set(*values).send(method)
              result.class.should be(Enumerator)
              result.each { |x| x == item}.should == expected
            end
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.1849904397705545, 'fraction_numerical': 0.0, 'mean_word_length': 1.6833333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2994475', 'n_tokens_mistral': 670, 'n_tokens_neox': 661, 'n_words': 203}