summaryrefslogtreecommitdiff
path: root/vendor/plugins/thinking-sphinx/features/step_definitions
diff options
context:
space:
mode:
authorUser <hukl@cccms.ccc.de>2011-02-10 14:23:36 +0100
committerUser <hukl@cccms.ccc.de>2011-02-10 14:23:36 +0100
commit384b187e9e067ddf2bb4d5fad0c2deaf96f69c89 (patch)
treecf743f377d3e2e28a31ae0359d95f37beba82cc3 /vendor/plugins/thinking-sphinx/features/step_definitions
parent3d0de09cf94cee6233b36a7f5ce20d5059854acc (diff)
parentcec2b1e2881db0000b2a09029154bea0fc62ade3 (diff)
Merge branch 'master' of ssh://svn.medienhaus.udk-berlin.de/usr/local/git/cccms
Diffstat (limited to 'vendor/plugins/thinking-sphinx/features/step_definitions')
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/alpha_steps.rb3
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/beta_steps.rb11
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/cat_steps.rb3
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/common_steps.rb154
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/datetime_delta_steps.rb15
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/delayed_delta_indexing_steps.rb7
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/extensible_delta_indexing_steps.rb7
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb72
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/find_arguments_steps.rb36
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/gamma_steps.rb15
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb66
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/sphinx_steps.rb27
12 files changed, 0 insertions, 416 deletions
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/alpha_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/alpha_steps.rb
deleted file mode 100644
index 987b10b..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/alpha_steps.rb
+++ /dev/null
@@ -1,3 +0,0 @@
1When /^I change the name of alpha (\w+) to (\w+)$/ do |current, replacement|
2 Alpha.find_by_name(current).update_attributes(:name => replacement)
3end \ No newline at end of file
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/beta_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/beta_steps.rb
deleted file mode 100644
index 2d566a1..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/beta_steps.rb
+++ /dev/null
@@ -1,11 +0,0 @@
1When /^I destroy beta (\w+)$/ do |name|
2 Beta.find_by_name(name).destroy
3end
4
5When /^I create a new beta named (\w+)$/ do |name|
6 Beta.create(:name => name)
7end
8
9When /^I change the name of beta (\w+) to (\w+)$/ do |current, replacement|
10 Beta.find_by_name(current).update_attributes(:name => replacement)
11end \ No newline at end of file
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/cat_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/cat_steps.rb
deleted file mode 100644
index 82b8b7f..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/cat_steps.rb
+++ /dev/null
@@ -1,3 +0,0 @@
1When /^I destroy cat (\w+)$/ do |name|
2 Cat.find_by_name(name).destroy
3end \ No newline at end of file
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/common_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/common_steps.rb
deleted file mode 100644
index de45a20..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/common_steps.rb
+++ /dev/null
@@ -1,154 +0,0 @@
1Before do
2 $queries_executed = []
3 ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
4
5 @model = nil
6 @method = :search
7 @query = ""
8 @conditions = {}
9 @with = {}
10 @without = {}
11 @with_all = {}
12 @options = {}
13end
14
15Given /^I am searching on (.+)$/ do |model|
16 @model = model.gsub(/\s/, '_').singularize.camelize.constantize
17end
18
19When /^I am searching for ids$/ do
20 @results = nil
21 @method = :search_for_ids
22end
23
24When /^I am retrieving the result count$/ do
25 @result = nil
26 @method = @model ? :search_count : :count
27end
28
29When /^I search for (\w+)$/ do |query|
30 @results = nil
31 @query = query
32end
33
34When /^I search for "([^\"]+)"$/ do |query|
35 @results = nil
36 @query = query
37end
38
39When /^I search for (\w+) on (\w+)$/ do |query, field|
40 @results = nil
41 @conditions[field.to_sym] = query
42end
43
44When /^I clear existing filters$/ do
45 @with = {}
46 @without = {}
47 @with_all = {}
48end
49
50When /^I filter by (\w+) on (\w+)$/ do |filter, attribute|
51 @results = nil
52 @with[attribute.to_sym] = filter.to_i
53end
54
55When /^I filter by (\d+) and (\d+) on (\w+)$/ do |value_one, value_two, attribute|
56 @results = nil
57 @with[attribute.to_sym] = [value_one.to_i, value_two.to_i]
58end
59
60When /^I filter by both (\d+) and (\d+) on (\w+)$/ do |value_one, value_two, attribute|
61 @results = nil
62 @with_all[attribute.to_sym] = [value_one.to_i, value_two.to_i]
63end
64
65When /^I filter between ([\d\.]+) and ([\d\.]+) on (\w+)$/ do |first, last, attribute|
66 @results = nil
67 if first[/\./].nil? && last[/\./].nil?
68 @with[attribute.to_sym] = first.to_i..last.to_i
69 else
70 @with[attribute.to_sym] = first.to_f..last.to_f
71 end
72end
73
74When /^I filter between (\d+) and (\d+) days ago on (\w+)$/ do |last, first, attribute|
75 @results = nil
76 @with[attribute.to_sym] = first.to_i.days.ago..last.to_i.days.ago
77end
78
79When /^I order by (\w+)$/ do |attribute|
80 @results = nil
81 @options[:order] = attribute.to_sym
82end
83
84When /^I order by "([^\"]+)"$/ do |str|
85 @results = nil
86 @options[:order] = str
87end
88
89When /^I group results by the (\w+) attribute$/ do |attribute|
90 @results = nil
91 @options[:group_function] = :attr
92 @options[:group_by] = attribute
93end
94
95When /^I set match mode to (\w+)$/ do |match_mode|
96 @results = nil
97 @options[:match_mode] = match_mode.to_sym
98end
99
100When /^I set per page to (\d+)$/ do |per_page|
101 @results = nil
102 @options[:per_page] = per_page.to_i
103end
104
105When /^I set retry stale to (\w+)$/ do |retry_stale|
106 @results = nil
107 @options[:retry_stale] = case retry_stale
108 when "true" then true
109 when "false" then false
110 else retry_stale.to_i
111 end
112end
113
114Then /^the (\w+) of each result should indicate order$/ do |attribute|
115 results.inject(nil) do |prev, current|
116 unless prev.nil?
117 current.send(attribute.to_sym).should >= prev.send(attribute.to_sym)
118 end
119
120 current
121 end
122end
123
124Then /^I can iterate by result and (\w+)$/ do |attribute|
125 iteration = lambda { |result, attr_value|
126 result.should be_kind_of(@model)
127 unless attribute == "group" && attr_value.nil?
128 attr_value.should be_kind_of(Integer)
129 end
130 }
131
132 results.send("each_with_#{attribute}", &iteration)
133end
134
135Then /^I should get (\d+) results?$/ do |count|
136 results.length.should == count.to_i
137end
138
139Then /^I should not get (\d+) results?$/ do |count|
140 results.length.should_not == count.to_i
141end
142
143def results
144 @results ||= (@model || ThinkingSphinx::Search).send(
145 @method,
146 @query,
147 @options.merge(
148 :conditions => @conditions,
149 :with => @with,
150 :without => @without,
151 :with_all => @with_all
152 )
153 )
154end \ No newline at end of file
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/datetime_delta_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/datetime_delta_steps.rb
deleted file mode 100644
index b1d87fe..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/datetime_delta_steps.rb
+++ /dev/null
@@ -1,15 +0,0 @@
1When /^I index the theta datetime delta$/ do
2 Theta.sphinx_indexes.first.delta_object.delayed_index(Theta)
3end
4
5When /^I change the name of theta (\w+) to (\w+)$/ do |current, replacement|
6 Theta.find_by_name(current).update_attributes(:name => replacement)
7end
8
9When /^I create a new theta named (\w+)$/ do |name|
10 Theta.create(:name => name)
11end
12
13When /^I delete the theta named (\w+)$/ do |name|
14 Theta.find_by_name(name).destroy
15end
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/delayed_delta_indexing_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/delayed_delta_indexing_steps.rb
deleted file mode 100644
index dc30ee5..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/delayed_delta_indexing_steps.rb
+++ /dev/null
@@ -1,7 +0,0 @@
1When /^I run the delayed jobs$/ do
2 Delayed::Job.work_off.inspect
3end
4
5When /^I change the name of delayed beta (\w+) to (\w+)$/ do |current, replacement|
6 DelayedBeta.find_by_name(current).update_attributes(:name => replacement)
7end
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/extensible_delta_indexing_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/extensible_delta_indexing_steps.rb
deleted file mode 100644
index 472e112..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/extensible_delta_indexing_steps.rb
+++ /dev/null
@@ -1,7 +0,0 @@
1When /I change the name of extensible beta (\w+) to (\w+)$/ do |current, replacement|
2 ExtensibleBeta.find_by_name(current).update_attributes(:name => replacement)
3end
4
5Then /^the generic delta handler should handle the delta indexing$/ do
6 ExtensibleBeta.find(:first, :conditions => {:changed_by_generic => true}).should_not be_nil
7end \ No newline at end of file
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb
deleted file mode 100644
index b788529..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb
+++ /dev/null
@@ -1,72 +0,0 @@
1When "I am requesting facet results$" do
2 @results = nil
3 @method = :facets
4end
5
6When "I want classes included" do
7 @options[:class_facet] = true
8end
9
10When "I don't want classes included" do
11 @options[:class_facet] = false
12end
13
14When "I want all possible attributes" do
15 @options[:all_attributes] = true
16end
17
18When /^I drill down where (\w+) is (\w+)$/ do |facet, value|
19 @results = results.for(facet.downcase.to_sym => value)
20end
21
22When /^I drill down where (\w+) is (\w+) and (\w+) is (\w+)$/ do |facet_one, value_one, facet_two, value_two|
23 value_one = value_one.to_i unless value_one[/^\d+$/].nil?
24 value_two = value_two.to_i unless value_two[/^\d+$/].nil?
25
26 @results = results.for(
27 facet_one.downcase.to_sym => value_one,
28 facet_two.downcase.to_sym => value_two
29 )
30end
31
32When /^I drill down where ([\w_]+) includes the id of tag (\w+)$/ do |facet, text|
33 tag = Tag.find_by_text(text)
34 @results = results.for(facet.downcase.to_sym => tag.id)
35end
36
37When /^I drill down where ([\w_]+) includes the id of tags (\w+) or (\w+)$/ do |facet, text_one, text_two|
38 tag_one = Tag.find_by_text(text_one)
39 tag_two = Tag.find_by_text(text_two)
40 @results = results.for(facet.downcase.to_sym => [tag_one.id, tag_two.id])
41end
42
43Then "I should have valid facet results" do
44 results.should be_kind_of(Hash)
45 results.values.each { |value| value.should be_kind_of(Hash) }
46end
47
48Then /^I should have (\d+) facets?$/ do |count|
49 results.keys.length.should == count.to_i
50end
51
52Then /^I should have the facet ([\w_\s]+)$/ do |name|
53 results[facet_name(name)].should be_kind_of(Hash)
54end
55
56Then /^I should not have the facet ([\w_\s]+)$/ do |name|
57 results.keys.should_not include(facet_name(name))
58end
59
60Then /^the ([\w_\s]+) facet should have a "([\w\s_]+)" key with (\d+) hits$/ do |name, key, hit_count|
61 facet_name = facet_name name
62 results[facet_name].keys.should include(key)
63 results[facet_name][key].should eql(hit_count.to_i)
64end
65
66Then /^the ([\w_\s]+) facet should have a "(\w+)" key$/ do |name, key|
67 results[facet_name(name)].keys.should include(key)
68end
69
70def facet_name(string)
71 string.gsub(/\s/, '').underscore.to_sym
72end
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/find_arguments_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/find_arguments_steps.rb
deleted file mode 100644
index 65f889c..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/find_arguments_steps.rb
+++ /dev/null
@@ -1,36 +0,0 @@
1When "I include comments" do
2 @results = nil
3 @options[:include] = :comments
4end
5
6When /^I get the first comment$/ do
7 @comment = Comment.find(:first)
8end
9
10When /^I track queries$/ do
11 $queries_executed = []
12end
13
14When /^I compare comments$/ do
15 results.first.comments.first.should == @comment
16end
17
18When /^I select only content$/ do
19 @results = nil
20 @options[:select] = "id, content"
21end
22
23Then /^I should have (\d+) quer[yies]+$/ do |count|
24 $queries_executed.length.should == count.to_i
25end
26
27Then /^I should not get an error accessing the subject$/ do
28 lambda { results.first.subject }.should_not raise_error
29end
30
31Then /^I should get an error accessing the subject$/ do
32 error_class = NoMethodError
33 error_class = ActiveRecord::MissingAttributeError if ActiveRecord.constants.include?("MissingAttributeError")
34
35 lambda { results.first.subject }.should raise_error(error_class)
36end
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/gamma_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/gamma_steps.rb
deleted file mode 100644
index c4fbe20..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/gamma_steps.rb
+++ /dev/null
@@ -1,15 +0,0 @@
1When /^I destroy gamma (\w+) without callbacks$/ do |name|
2 @results = nil
3 gamma = Gamma.find_by_name(name)
4 Gamma.delete(gamma.id) if gamma
5end
6
7Then "I should get a single result of nil" do
8 results.should == [nil]
9end
10
11Then /^I should get a single gamma result with a name of (\w+)$/ do |name|
12 results.length.should == 1
13 results.first.should be_kind_of(Gamma)
14 results.first.name.should == name
15end
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb
deleted file mode 100644
index 8c64dd7..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb
+++ /dev/null
@@ -1,66 +0,0 @@
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
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/sphinx_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/sphinx_steps.rb
deleted file mode 100644
index 1633249..0000000
--- a/vendor/plugins/thinking-sphinx/features/step_definitions/sphinx_steps.rb
+++ /dev/null
@@ -1,27 +0,0 @@
1Given "Sphinx is running" do
2 ThinkingSphinx::Configuration.instance.controller.should be_running
3end
4
5When "I kill the Sphinx process" do
6 Process.kill(9, ThinkingSphinx.sphinx_pid.to_i)
7end
8
9When "I wait for Sphinx to catch up" do
10 sleep(0.25)
11end
12
13When "I start Sphinx" do
14 ThinkingSphinx::Configuration.instance.controller.start
15end
16
17When "I stop Sphinx" do
18 ThinkingSphinx::Configuration.instance.controller.stop
19end
20
21Then "Sphinx should be running" do
22 ThinkingSphinx.sphinx_running?.should be_true
23end
24
25Then "Sphinx should not be running" do
26 ThinkingSphinx.sphinx_running?.should be_false
27end