<commit_before>require 'chef_zero/solr/solr_parser'
require 'chef_zero/solr/solr_doc'

#p = ChefZero::Solr::SolrParser.new('chef_environment:prod AND roles:redis_history_server AND -redis_slaveof:[a TO z]')

describe ChefZero::Solr::SolrParser do
  let (:all_docs) do
    docs = []
    [{'foo' => 1},
     {'foo' => 7}].each_with_index do |h, i|
      docs.push ChefZero::Solr::SolrDoc.new(h, i)
    end
    docs
  end

  it "handles terms" do
    q = ChefZero::Solr::SolrParser.new('foo:7').parse
    results = all_docs.select {|doc| q.matches_doc?(doc) }
    results.size.should eq(1)
  end

  it "handles ranges" do
    q = ChefZero::Solr::SolrParser.new('foo:[1 TO 5]').parse
    results = all_docs.select {|doc| q.matches_doc?(doc) }
    results.size.should eq(1)
  end
end<commit_msg>switch to string tests for less confusion.<commit_after>require 'chef_zero/solr/solr_parser'
require 'chef_zero/solr/solr_doc'

#p = ChefZero::Solr::SolrParser.new('chef_environment:prod AND roles:redis_history_server AND -redis_slaveof:[a TO z]')

describe ChefZero::Solr::SolrParser do
  let (:all_docs) do
    docs = []
    [{'foo' => 'a'},
     {'foo' => 'd'}].each_with_index do |h, i|
      docs.push ChefZero::Solr::SolrDoc.new(h, i)
    end
    docs
  end

  it "handles terms" do
    q = ChefZero::Solr::SolrParser.new('foo:d').parse
    results = all_docs.select {|doc| q.matches_doc?(doc) }
    results.size.should eq(1)
  end

  it "handles ranges" do
    q = ChefZero::Solr::SolrParser.new('foo:[a TO c]').parse
    results = all_docs.select {|doc| q.matches_doc?(doc) }
    results.size.should eq(1)
  end
end
{'fraction_non_alphanumeric': 0.1568505889646621, 'fraction_numerical': 0.005579665220086794, 'mean_word_length': 3.950920245398773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6158451', 'n_tokens_mistral': 674, 'n_tokens_neox': 626, 'n_words': 127}