diff options
| author | hukl <contact@smyck.org> | 2009-04-28 00:15:53 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-05-01 17:14:02 +0200 |
| commit | 4bd16f053847f2efe347ebda9136ef2233ee0d2c (patch) | |
| tree | f4c11f89455de991c8d87726d5757b752e7129e2 /vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb | |
| parent | d3a9b46ba5c863a0ff377dcffae9a494fe476e02 (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.rb | 72 |
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 @@ | |||
| 1 | When "I am requesting facet results$" do | ||
| 2 | @results = nil | ||
| 3 | @method = :facets | ||
| 4 | end | ||
| 5 | |||
| 6 | When "I want classes included" do | ||
| 7 | @options[:class_facet] = true | ||
| 8 | end | ||
| 9 | |||
| 10 | When "I don't want classes included" do | ||
| 11 | @options[:class_facet] = false | ||
| 12 | end | ||
| 13 | |||
| 14 | When "I want all possible attributes" do | ||
| 15 | @options[:all_attributes] = true | ||
| 16 | end | ||
| 17 | |||
| 18 | When /^I drill down where (\w+) is (\w+)$/ do |facet, value| | ||
| 19 | @results = results.for(facet.downcase.to_sym => value) | ||
| 20 | end | ||
| 21 | |||
| 22 | When /^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 | ) | ||
| 30 | end | ||
| 31 | |||
| 32 | When /^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) | ||
| 35 | end | ||
| 36 | |||
| 37 | When /^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]) | ||
| 41 | end | ||
| 42 | |||
| 43 | Then "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) } | ||
| 46 | end | ||
| 47 | |||
| 48 | Then /^I should have (\d+) facets?$/ do |count| | ||
| 49 | results.keys.length.should == count.to_i | ||
| 50 | end | ||
| 51 | |||
| 52 | Then /^I should have the facet ([\w_\s]+)$/ do |name| | ||
| 53 | results[facet_name(name)].should be_kind_of(Hash) | ||
| 54 | end | ||
| 55 | |||
| 56 | Then /^I should not have the facet ([\w_\s]+)$/ do |name| | ||
| 57 | results.keys.should_not include(facet_name(name)) | ||
| 58 | end | ||
| 59 | |||
| 60 | Then /^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) | ||
| 64 | end | ||
| 65 | |||
| 66 | Then /^the ([\w_\s]+) facet should have a "(\w+)" key$/ do |name, key| | ||
| 67 | results[facet_name(name)].keys.should include(key) | ||
| 68 | end | ||
| 69 | |||
| 70 | def facet_name(string) | ||
| 71 | string.gsub(/\s/, '').underscore.to_sym | ||
| 72 | end | ||
