summaryrefslogtreecommitdiff
path: root/vendor/plugins/thinking-sphinx/features/step_definitions/facet_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/facet_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/facet_steps.rb')
-rw-r--r--vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb72
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb b/vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb
new file mode 100644
index 0000000..b788529
--- /dev/null
+++ b/vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb
@@ -0,0 +1,72 @@
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