blob: 8c64dd7742b5cf2ef10e058e988b3d6d76a6826b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
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.should == normal_results.collect(&:id)
end
Then /^I should get a value of (\d+)$/ do |count|
results.should == count.to_i
end
|