summaryrefslogtreecommitdiff
path: root/vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-04-28 00:15:53 +0200
committerhukl <contact@smyck.org>2009-05-01 17:14:02 +0200
commit4bd16f053847f2efe347ebda9136ef2233ee0d2c (patch)
treef4c11f89455de991c8d87726d5757b752e7129e2 /vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb
parentd3a9b46ba5c863a0ff377dcffae9a494fe476e02 (diff)
added thinking_sphinx plugin for fulltext search on nodes and heads
Diffstat (limited to 'vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb')
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb
new file mode 100644
index 0000000..8c64dd7
--- /dev/null
+++ b/vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb
@@ -0,0 +1,66 @@
1When /^I search for the specific id of (\d+) in the (\w+) index$/ do |id, index|
2 @id = id.to_i
3 @index = index
4end
5
6When /^I search for the document id of (\w+) (\w+) in the (\w+) index$/ do |model, name, index|
7 model = model.gsub(/\s/, '_').camelize.constantize
8 @id = model.find_by_name(name).sphinx_document_id
9 @index = index
10end
11
12Then "it should exist" do
13 ThinkingSphinx::Search.search_for_id(@id, @index).should == true
14end
15
16Then "it should not exist" do
17 ThinkingSphinx::Search.search_for_id(@id, @index).should == false
18end
19
20Then "it should exist if using Rails 2.1 or newer" do
21 require 'active_record/version'
22 unless ActiveRecord::VERSION::STRING.to_f < 2.1
23 ThinkingSphinx::Search.search_for_id(@id, @index).should == true
24 end
25end
26
27Then "it should not exist if using Rails 2.1 or newer" do
28 require 'active_record/version'
29 unless ActiveRecord::VERSION::STRING.to_f < 2.1
30 ThinkingSphinx::Search.search_for_id(@id, @index).should == false
31 end
32end
33
34Then /^I can iterate by result and group and count$/ do
35 results.each_with_groupby_and_count do |result, group, count|
36 result.should be_kind_of(@model)
37 count.should be_kind_of(Integer)
38 group.should be_kind_of(Integer)
39 end
40end
41
42Then "each result id should match the corresponding sphinx internal id" do
43 results.each_with_sphinx_internal_id do |result, id|
44 result.id.should == id
45 end
46end
47
48Then "I should have an array of integers" do
49 results.each do |result|
50 result.should be_kind_of(Integer)
51 end
52end
53
54Then "searching for ids should match the record ids of the normal search results" do
55 normal_results = results
56
57 # reset search, switch method
58 @results = nil
59 @method = :search_for_ids
60
61 results.should == normal_results.collect(&:id)
62end
63
64Then /^I should get a value of (\d+)$/ do |count|
65 results.should == count.to_i
66end \ No newline at end of file