<commit_before>require 'spidr/rules'

require 'spec_helper'

describe Rules do
  it "should accept data based on acceptance data" do
    rules = Rules.new(:accept => [1])

    rules.accept?(1).should == true
  end

  it "should accept data based on acceptance regexps" do
    rules = Rules.new(:accept => [/1/])

    rules.accept?('1').should == true
  end

  it "should match non-Strings using acceptance regexps" do
    rules = Rules.new(:accept => [/1/])

    rules.accept?(1).should == true
  end

  it "should accept data using acceptance lambdas" do
    rules = Rules.new(:accept => [lambda { |data| data > 2 }])

    rules.accept?(3).should == true
  end

  it "should reject data that does not match any acceptance rules" do
    rules = Rules.new(:accept => [1, 2, 3])

    rules.accept?(2).should == true
    rules.accept?(4).should == false
  end

  it "should accept data that does not match any rejection rules" do
    rules = Rules.new(:reject => [1, 2, 3])
<commit_msg>Use the terminology "patterns" wrt to specing Spidr::Rules.<commit_after>require 'spidr/rules'

require 'spec_helper'

describe Rules do
  it "should accept data based on acceptance data" do
    rules = Rules.new(:accept => [1])

    rules.accept?(1).should == true
  end

  it "should accept data based on acceptance regexps" do
    rules = Rules.new(:accept => [/1/])

    rules.accept?('1').should == true
  end

  it "should match non-Strings using acceptance regexps" do
    rules = Rules.new(:accept => [/1/])

    rules.accept?(1).should == true
  end

  it "should accept data using acceptance lambdas" do
    rules = Rules.new(:accept => [lambda { |data| data > 2 }])

    rules.accept?(3).should == true
  end

  it "should reject data that does not match any acceptance patterns" do
    rules = Rules.new(:accept => [1, 2, 3])

    rules.accept?(2).should == true
    rules.accept?(4).should == false
  end

  it "should accept data that does not match any rejection patterns" do
    rules = Rules.new(:reject => [1, 2, 3])

{'fraction_non_alphanumeric': 0.13330029732408324, 'fraction_numerical': 0.015857284440039643, 'mean_word_length': 3.2327044025157234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5856964', 'n_tokens_mistral': 648, 'n_tokens_neox': 619, 'n_words': 221}