<commit_before># encoding: UTF-8
When /^I search for the specific id of (\d+) in the (\w+) index$/ do |id, index|
  @id     = id.to_i
  @index  = index
end

When /^I search for the document id of (\w+) (\w+) in the (\w+) index$/ do |model, name, index|
  model   = model.gsub(/\s/, '_').camelize.constantize
  @id     = model.find_by_name(name).sphinx_document_id
  @index  = index
end

Then "it should exist" do
  ThinkingSphinx::Search.search_for_id(@id, @index).should == true
end

Then "it should not exist" do
  ThinkingSphinx::Search.search_for_id(@id, @index).should == false
end

Then "it should exist if using Rails 2.1 or newer" do
  require 'active_record/version'
  unless ActiveRecord::VERSION::STRING.to_f < 2.1
    ThinkingSphinx::Search.search_for_id(@id, @index).should == true
  end
end

Then "it should not exist if using Rails 2.1 or newer" do
  require 'active_record/version'
  unless ActiveRecord::VERSION::STRING.to_f < 2.1
    ThinkingSphinx::Search.search_for_id(@id, @index).should == false
  end
end

Then /^I can iterate by result and group and count$/ do
  results.each_with_groupby_and_count do |result, group, count|
    result.should be_kind_of(@model)
    count.should  be_kind_of(Integer)
    group.should  be_kind_of(Integer)
  end
end

Then "each result id should match the corresponding sphinx internal id" do
  results.each_with_sphinx_internal_id do |result, id|
    result.id.should == id
  end
end

Then "I should have an array of integers" do
  results.each do |result|
    result.should be_kind_of(Integer)
  end
end

Then "searching for ids should match the record ids of the normal search results" do
  normal_results = results
  
  # reset search, switch method
  @results = nil
  @method  = :search_for_ids
  
  results.to_a.should == normal_results.collect(&:id)<commit_msg>Switch from deprecated code in feature steps.<commit_after># encoding: UTF-8
When /^I search for the specific id of (\d+) in the (\w+) index$/ do |id, index|
  @id     = id.to_i
  @index  = index
end

When /^I search for the document id of (\w+) (\w+) in the (\w+) index$/ do |model, name, index|
  model   = model.gsub(/\s/, '_').camelize.constantize
  @id     = model.find_by_name(name).sphinx_document_id
  @index  = index
end

Then "it should exist" do
  ThinkingSphinx.search_for_id(@id, @index).should == true
end

Then "it should not exist" do
  ThinkingSphinx.search_for_id(@id, @index).should == false
end

Then "it should exist if using Rails 2.1 or newer" do
  require 'active_record/version'
  unless ActiveRecord::VERSION::STRING.to_f < 2.1
    ThinkingSphinx.search_for_id(@id, @index).should == true
  end
end

Then "it should not exist if using Rails 2.1 or newer" do
  require 'active_record/version'
  unless ActiveRecord::VERSION::STRING.to_f < 2.1
    ThinkingSphinx.search_for_id(@id, @index).should == false
  end
end

Then /^I can iterate by result and group and count$/ do
  results.each_with_groupby_and_count do |result, group, count|
    result.should be_kind_of(@model)
    count.should  be_kind_of(Integer)
    group.should  be_kind_of(Integer)
  end
end

Then "each result id should match the corresponding sphinx internal id" do
  results.each_with_sphinx_internal_id do |result, id|
    result.id.should == id
  end
end

Then "I should have an array of integers" do
  results.each do |result|
    result.should be_kind_of(Integer)
  end
end

Then "searching for ids should match the record ids of the normal search results" do
  normal_results = results
  
  # reset search, switch method
  @results = nil
  @method  = :search_for_ids
  
  results.to_a.should == normal_results.collect(&:id)
{'fraction_non_alphanumeric': 0.10559517279210093, 'fraction_numerical': 0.004936917169500823, 'mean_word_length': 3.875668449197861, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3735685', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1231, 'n_words': 403}