blacklight 3.0pre1 → 3.0pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +0 -6
- data/README.rdoc +94 -87
- data/blacklight.gemspec +1 -1
- data/config/routes.rb +1 -1
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/catalog.rb +10 -12
- data/lib/blacklight/controller.rb +2 -2
- data/lib/blacklight/engine.rb +5 -2
- data/lib/blacklight/solr/document.rb +1 -1
- data/lib/blacklight/solr/document/marc.rb +1 -16
- data/lib/blacklight/solr_helper.rb +43 -14
- data/lib/blacklight/version.rb +1 -1
- data/lib/generators/blacklight/assets_generator.rb +25 -0
- data/lib/generators/blacklight/blacklight_generator.rb +16 -1
- data/lib/generators/blacklight/jetty_generator.rb +101 -0
- data/lib/generators/blacklight/solr_conf_generator.rb +25 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +0 -1
- data/lib/generators/blacklight/templates/config/solr.yml +14 -2
- data/lib/generators/blacklight/templates/public/images/{blacklight/bg.png → bg.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/border.png → border.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/bul_sq_gry.gif → bul_sq_gry.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/checkmark.gif → checkmark.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/logo.png → logo.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/magnifying_glass.gif → magnifying_glass.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/remove.gif → remove.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/separator.gif → separator.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/start_over.gif → start_over.gif} +0 -0
- data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +5 -0
- data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +9 -3
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +339 -0
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +578 -0
- data/lib/railties/all_tests.rake +11 -0
- data/lib/railties/blacklight.rake +0 -52
- data/lib/railties/blacklight_cucumber.rake +125 -0
- data/lib/railties/blacklight_rspec.rake +128 -0
- data/lib/railties/{test_solr_server.rb → jetty_solr_server.rb} +22 -45
- data/lib/railties/solr_marc.rake +24 -5
- data/test_support/.rspec +1 -0
- data/test_support/data/test_data.utf8.mrc +1 -0
- data/test_support/features/bookmarks.feature +88 -0
- data/test_support/features/did_you_mean.feature +129 -0
- data/test_support/features/folder.feature +67 -0
- data/test_support/features/librarian_view.feature +17 -0
- data/test_support/features/record_view.feature +34 -0
- data/test_support/features/saved_searches.feature +49 -0
- data/test_support/features/search.feature +86 -0
- data/test_support/features/search_filters.feature +121 -0
- data/test_support/features/search_history.feature +95 -0
- data/test_support/features/search_results.feature +61 -0
- data/test_support/features/search_sort.feature +29 -0
- data/test_support/features/step_definitions/bookmarks_steps.rb +5 -0
- data/test_support/features/step_definitions/error_steps.rb +4 -0
- data/test_support/features/step_definitions/folder_steps.rb +26 -0
- data/test_support/features/step_definitions/general_steps.rb +49 -0
- data/test_support/features/step_definitions/record_view_steps.rb +11 -0
- data/test_support/features/step_definitions/saved_searches_steps.rb +21 -0
- data/test_support/features/step_definitions/search_facets_steps.rb +28 -0
- data/test_support/features/step_definitions/search_history_steps.rb +8 -0
- data/test_support/features/step_definitions/search_result_steps.rb +113 -0
- data/test_support/features/step_definitions/search_steps.rb +102 -0
- data/test_support/features/step_definitions/user_steps.rb +4 -0
- data/test_support/features/step_definitions/web_steps.rb +211 -0
- data/test_support/features/support/env.rb +49 -0
- data/test_support/features/support/paths.rb +55 -0
- data/test_support/features/support/selectors.rb +39 -0
- data/test_support/features/unapi.feature +30 -0
- data/test_support/spec/controllers/application_controller_spec.rb +22 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +480 -0
- data/test_support/spec/controllers/folder_controller_spec.rb +40 -0
- data/test_support/spec/controllers/search_history_controller_spec.rb +45 -0
- data/test_support/spec/data/sample_docs.yml +655 -0
- data/test_support/spec/data/test_data.utf8.mrc +1 -0
- data/test_support/spec/helpers/blacklight_helper_spec.rb +482 -0
- data/test_support/spec/helpers/hash_as_hidden_fields_spec.rb +23 -0
- data/test_support/spec/helpers/render_constraints_helper_spec.rb +64 -0
- data/test_support/spec/helpers/search_history_helper_spec.rb +11 -0
- data/test_support/spec/helpers/solr_helper_spec.rb +873 -0
- data/test_support/spec/lib/blacklight_email_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_sms_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_solr_document_dublin_core_spec.rb +41 -0
- data/test_support/spec/lib/blacklight_solr_document_marc_spec.rb +88 -0
- data/test_support/spec/lib/blacklight_solr_document_spec.rb +173 -0
- data/test_support/spec/lib/blacklight_spec.rb +39 -0
- data/test_support/spec/lib/configurable_spec.rb +97 -0
- data/test_support/spec/lib/facet_paginator_spec.rb +93 -0
- data/test_support/spec/lib/marc_export_spec.rb +444 -0
- data/test_support/spec/lib/search_fields_spec.rb +105 -0
- data/test_support/spec/lib/tasks/blacklight_task_spec.rb +21 -0
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +59 -0
- data/test_support/spec/models/bookmark_spec.rb +37 -0
- data/test_support/spec/models/record_mailer_spec.rb +67 -0
- data/test_support/spec/models/search_spec.rb +55 -0
- data/test_support/spec/models/solr_docment_spec.rb +111 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +38 -0
- data/test_support/spec/support/action_controller.rb +42 -0
- data/test_support/spec/support/assert_difference.rb +16 -0
- data/test_support/spec/support/include_text.rb +20 -0
- data/test_support/spec/views/catalog/_constraints_element.html.erb_spec.rb +59 -0
- data/test_support/spec/views/catalog/_document_list.html.erb_spec.rb +8 -0
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +182 -0
- data/test_support/spec/views/catalog/_index_partials/_default.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/_show_partials/_default.html.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +141 -0
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +100 -0
- data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +45 -0
- metadata +95 -98
- data/lib/blacklight/marc.rb +0 -46
- data/lib/blacklight/marc/citation.rb +0 -251
- data/lib/railties/cucumber.rake +0 -53
- data/lib/railties/rspec.rake +0 -188
- data/spec/helpers/catalog_helper_spec.rb +0 -111
- data/spec/views/catalog/_sms_form.html.erb_spec.rb +0 -19
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#include Blacklight::SolrHelper
|
|
2
|
+
|
|
3
|
+
When /^I fill in the search box with "(.*?)"$/ do |query|
|
|
4
|
+
query.gsub!(/\\"/, '"')
|
|
5
|
+
fill_in(:q, :with => query)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Then /^I should get (at least|at most|exactly) (\d+) results?$/i do |comparator, comparison_num|
|
|
10
|
+
number_of_records = get_number_of_results_from_page(page)
|
|
11
|
+
|
|
12
|
+
case comparator
|
|
13
|
+
when "at least"
|
|
14
|
+
number_of_records.should >= comparison_num.to_i
|
|
15
|
+
when "at most"
|
|
16
|
+
number_of_records.should <= comparison_num.to_i
|
|
17
|
+
when "exactly"
|
|
18
|
+
number_of_records.should == comparison_num.to_i
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Then /^I should have (the same number of|fewer|more) results (?:than|as) a(?:n?) search for "(.*)"$/i do |comparator, query|
|
|
24
|
+
query.gsub!(/\\"/, '"')
|
|
25
|
+
number_of_records = get_number_of_results_from_page(page)
|
|
26
|
+
|
|
27
|
+
case comparator
|
|
28
|
+
when "the same number of"
|
|
29
|
+
get_number_of_results_for_query(query).should == number_of_records
|
|
30
|
+
when "fewer"
|
|
31
|
+
get_number_of_results_for_query(query).should > number_of_records
|
|
32
|
+
when "fewer"
|
|
33
|
+
get_number_of_results_for_query(query).should < number_of_records
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Then /^I should get id "([^\"]+)" in the results$/i do |id|
|
|
38
|
+
page.should have_xpath("//a[contains(@href, #{id})]")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Then /^I should not get id "([^\"]+)" in the results$/i do |id|
|
|
42
|
+
page.should_not have_xpath("//a[contains(@href, #{id})]")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Then /^I should get id "([^\"]+)" in the first (\d+) results?$/i do |id, max_num|
|
|
46
|
+
pos = get_position_in_result_page(page, id)
|
|
47
|
+
pos.should_not == -1
|
|
48
|
+
pos.should < max_num.to_i
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
Then /^I should not get id "([^\"]+)" in the first (\d+) results?$/i do |id, max_num|
|
|
52
|
+
pos = get_position_in_result_page(page, id)
|
|
53
|
+
pos.should_not == -1
|
|
54
|
+
|
|
55
|
+
if pos > 0
|
|
56
|
+
pos.should >= max_num.to_i
|
|
57
|
+
else
|
|
58
|
+
pos.should == -1 if pos == -1
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
Then /^I should get id "([^\"]+)" before id "([^\"]+)"$/i do |id1, id2|
|
|
63
|
+
pos1 = get_position_in_result_page(page, id1)
|
|
64
|
+
pos2 = get_position_in_result_page(page, id2)
|
|
65
|
+
pos1.should_not == -1
|
|
66
|
+
pos2.should_not == -1
|
|
67
|
+
|
|
68
|
+
pos1.should < pos2
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Then /^I should get id "([^\"]+)" and id "([^\"]+)" no more than (\d+) positions? from each other$/i do |id1, id2, limit|
|
|
72
|
+
|
|
73
|
+
pos1 = get_position_in_result_page(page, id1)
|
|
74
|
+
pos2 = get_position_in_result_page(page, id2)
|
|
75
|
+
pos1.should_not == -1
|
|
76
|
+
pos2.should_not == -1
|
|
77
|
+
|
|
78
|
+
(pos1 - pos2).abs.should <= limit.to_i
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
Then /^I should get at least (\d+) of these ids in the first (\d+) results: "([^\"]+)"$/i do |how_many, limit, id_string|
|
|
82
|
+
id_string.split(/,/).select do |id|
|
|
83
|
+
pos = get_position_in_result_page(page, id)
|
|
84
|
+
pos != -1 and pos < limit.to_i
|
|
85
|
+
end.length.should >= how_many.to_i
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Then /^I (should not|should) see an? "([^\"]*)" element with an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,elem,attribute,value|
|
|
89
|
+
if bool == "should not"
|
|
90
|
+
page.should_not have_selector("#{elem}[#{attribute}=#{value}]")
|
|
91
|
+
else
|
|
92
|
+
page.should have_selector("#{elem}[#{attribute}=#{value}]")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def get_position_in_result_page(page, id)
|
|
97
|
+
i = -1
|
|
98
|
+
page.all(".index_title a").each_with_index do |link, idx|
|
|
99
|
+
i = (idx+1) if link['href'] =~ Regexp.new(Regexp.escape(id) + "$")
|
|
100
|
+
end
|
|
101
|
+
i.to_i
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def get_number_of_results_for_query(query)
|
|
105
|
+
visit root_path
|
|
106
|
+
fill_in "q", :with => query
|
|
107
|
+
click_button "search"
|
|
108
|
+
get_number_of_results_from_page(page)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def get_number_of_results_from_page(page)
|
|
112
|
+
page.find("meta[name=totalResults]")['content'].to_i rescue 0
|
|
113
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# User added
|
|
2
|
+
Then /^I should see a search field$/ do
|
|
3
|
+
page.should have_selector("input#q")
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Then /^I should see a selectable list with field choices$/ do
|
|
7
|
+
page.should have_selector("select#search_field")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Then /^I should see a selectable list with per page choices$/ do
|
|
11
|
+
page.should have_selector("select#per_page")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Then /^I should see a "([^\"]*)" button$/ do |label|
|
|
15
|
+
page.should have_selector("input[type='submit'][value='#{label}']")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Then /^I should not see the "([^\"]*)" element$/ do |id|
|
|
19
|
+
page.should_not have_selector("##{id}")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Then /^I should see the "([^\"]*)" element$/ do |id|
|
|
23
|
+
page.should have_selector("##{id}")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Given /^the application is configured to have searchable fields "([^\"]*)" with values "([^\"]*)"$/ do |fields, values|
|
|
27
|
+
labels = fields.split(", ")
|
|
28
|
+
values = values.split(", ")
|
|
29
|
+
combined = labels.zip(values)
|
|
30
|
+
Blacklight.config[:search_fields] = []
|
|
31
|
+
combined.each do |pair|
|
|
32
|
+
Blacklight.config[:search_fields] << pair
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Then /^I should see select list "([^\"]*)" with field labels "([^\"]*)"$/ do |list_css, names|
|
|
37
|
+
page.should have_selector(list_css) do
|
|
38
|
+
labels = names.split(", ")
|
|
39
|
+
labels.each do |label|
|
|
40
|
+
with_tag('option', label)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Then /^I should see select list "([^\"]*)" with "([^\"]*)" selected$/ do |list_css, label|
|
|
46
|
+
page.should have_selector(list_css) do |e|
|
|
47
|
+
with_tag("[selected=selected]", {:count => 1}) do
|
|
48
|
+
with_tag("option", {:count => 1, :text => label})
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Results Page
|
|
54
|
+
Given /^the application is configured to have sort fields "([^\"]*)" with values "([^\"]*)"$/ do |fields, values|
|
|
55
|
+
labels = fields.split(", ")
|
|
56
|
+
values = values.split(", ")
|
|
57
|
+
combined = labels.zip(values)
|
|
58
|
+
Blacklight.config[:sort_fields] = []
|
|
59
|
+
combined.each do |pair|
|
|
60
|
+
Blacklight.config[:sort_fields] << pair
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
Then /^I should get results$/ do
|
|
65
|
+
page.should have_selector("div.document")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
Then /^I should not get results$/ do
|
|
69
|
+
page.should_not have_selector("div.document")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Then /^I should see the applied filter "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
|
|
73
|
+
page.should have_selector("div#facets div h3", :content => filter)
|
|
74
|
+
page.should have_selector("div#facets div span.selected", :content => text)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
Then /^I should see an rss discovery link/ do
|
|
78
|
+
page.should have_selector("link[rel=alternate][type='application/rss+xml']")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
Then /^I should see an atom discovery link/ do
|
|
82
|
+
page.should have_selector("link[rel=alternate][type='application/atom+xml']")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
Then /^I should see an unAPI discovery link/ do
|
|
86
|
+
page.should have_selector("link[rel=unapi-server][type='application/xml']")
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
Then /^I should see opensearch response metadata tags/ do
|
|
90
|
+
page.should have_selector("meta[name=totalResults]")
|
|
91
|
+
page.should have_selector("meta[name=startIndex]")
|
|
92
|
+
page.should have_selector("meta[name=itemsPerPage]")
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Then /^I should see the applied filter "([^\"]*)" with the value
|
|
96
|
+
# "([^\"]*)"$/ do |filter, text|
|
|
97
|
+
# page.should have_tag("div#facets div") do |node|
|
|
98
|
+
# node.should have_selector("h3", :content => filter)
|
|
99
|
+
# node.should have_selector("span.selected", :content => /#{text}.*/)
|
|
100
|
+
# end
|
|
101
|
+
# end
|
|
102
|
+
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# TL;DR: YOU SHOULD DELETE THIS FILE
|
|
2
|
+
#
|
|
3
|
+
# This file iwas generated by Cucumber-Rails and is only here to get you a head start
|
|
4
|
+
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
|
|
5
|
+
# visit pages, interact with widgets and make assertions about page content.
|
|
6
|
+
#
|
|
7
|
+
# If you use these step definitions as basis for your features you will quickly end up
|
|
8
|
+
# with features that are:
|
|
9
|
+
#
|
|
10
|
+
# * Hard to maintain
|
|
11
|
+
# * Verbose to read
|
|
12
|
+
#
|
|
13
|
+
# A much better approach is to write your own higher level step definitions, following
|
|
14
|
+
# the advice in the following blog posts:
|
|
15
|
+
#
|
|
16
|
+
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
|
17
|
+
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
|
18
|
+
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
require 'uri'
|
|
23
|
+
require 'cgi'
|
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
|
26
|
+
|
|
27
|
+
module WithinHelpers
|
|
28
|
+
def with_scope(locator)
|
|
29
|
+
locator ? within(*selector_for(locator)) { yield } : yield
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
World(WithinHelpers)
|
|
33
|
+
|
|
34
|
+
# Single-line step scoper
|
|
35
|
+
When /^(.*) within ([^:]+)$/ do |step, parent|
|
|
36
|
+
with_scope(parent) { When step }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Multi-line step scoper
|
|
40
|
+
When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
|
|
41
|
+
with_scope(parent) { When "#{step}:", table_or_string }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
|
45
|
+
visit path_to(page_name)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
|
49
|
+
visit path_to(page_name)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
|
53
|
+
click_button(button)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
|
57
|
+
click_link(link)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
|
61
|
+
fill_in(field, :with => value)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
|
65
|
+
fill_in(field, :with => value)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Use this to fill in an entire form with data from a table. Example:
|
|
69
|
+
#
|
|
70
|
+
# When I fill in the following:
|
|
71
|
+
# | Account Number | 5002 |
|
|
72
|
+
# | Expiry date | 2009-11-01 |
|
|
73
|
+
# | Note | Nice guy |
|
|
74
|
+
# | Wants Email? | |
|
|
75
|
+
#
|
|
76
|
+
# TODO: Add support for checkbox, select og option
|
|
77
|
+
# based on naming conventions.
|
|
78
|
+
#
|
|
79
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
|
80
|
+
fields.rows_hash.each do |name, value|
|
|
81
|
+
When %{I fill in "#{name}" with "#{value}"}
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
|
86
|
+
select(value, :from => field)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
|
90
|
+
check(field)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
|
94
|
+
uncheck(field)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
|
98
|
+
choose(field)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
|
102
|
+
attach_file(field, File.expand_path(path))
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
|
106
|
+
if page.respond_to? :should
|
|
107
|
+
page.should have_content(text)
|
|
108
|
+
else
|
|
109
|
+
assert page.has_content?(text)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
|
114
|
+
regexp = Regexp.new(regexp)
|
|
115
|
+
|
|
116
|
+
if page.respond_to? :should
|
|
117
|
+
page.should have_xpath('//*', :text => regexp)
|
|
118
|
+
else
|
|
119
|
+
assert page.has_xpath?('//*', :text => regexp)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
|
124
|
+
if page.respond_to? :should
|
|
125
|
+
page.should have_no_content(text)
|
|
126
|
+
else
|
|
127
|
+
assert page.has_no_content?(text)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
|
132
|
+
regexp = Regexp.new(regexp)
|
|
133
|
+
|
|
134
|
+
if page.respond_to? :should
|
|
135
|
+
page.should have_no_xpath('//*', :text => regexp)
|
|
136
|
+
else
|
|
137
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
|
142
|
+
with_scope(parent) do
|
|
143
|
+
field = find_field(field)
|
|
144
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
145
|
+
if field_value.respond_to? :should
|
|
146
|
+
field_value.should =~ /#{value}/
|
|
147
|
+
else
|
|
148
|
+
assert_match(/#{value}/, field_value)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
|
154
|
+
with_scope(parent) do
|
|
155
|
+
field = find_field(field)
|
|
156
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
|
157
|
+
if field_value.respond_to? :should_not
|
|
158
|
+
field_value.should_not =~ /#{value}/
|
|
159
|
+
else
|
|
160
|
+
assert_no_match(/#{value}/, field_value)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
|
166
|
+
with_scope(parent) do
|
|
167
|
+
field_checked = find_field(label)['checked']
|
|
168
|
+
if field_checked.respond_to? :should
|
|
169
|
+
field_checked.should be_true
|
|
170
|
+
else
|
|
171
|
+
assert field_checked
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
|
177
|
+
with_scope(parent) do
|
|
178
|
+
field_checked = find_field(label)['checked']
|
|
179
|
+
if field_checked.respond_to? :should
|
|
180
|
+
field_checked.should be_false
|
|
181
|
+
else
|
|
182
|
+
assert !field_checked
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
|
188
|
+
current_path = URI.parse(current_url).path
|
|
189
|
+
if current_path.respond_to? :should
|
|
190
|
+
current_path.should == path_to(page_name)
|
|
191
|
+
else
|
|
192
|
+
assert_equal path_to(page_name), current_path
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|
197
|
+
query = URI.parse(current_url).query
|
|
198
|
+
actual_params = query ? CGI.parse(query) : {}
|
|
199
|
+
expected_params = {}
|
|
200
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
|
201
|
+
|
|
202
|
+
if actual_params.respond_to? :should
|
|
203
|
+
actual_params.should == expected_params
|
|
204
|
+
else
|
|
205
|
+
assert_equal expected_params, actual_params
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
Then /^show me the page$/ do
|
|
210
|
+
save_and_open_page
|
|
211
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# TL;DR: YOU SHOULD DELETE THIS FILE
|
|
2
|
+
#
|
|
3
|
+
# This file iwas generated by Cucumber-Rails and is only here to get you a head start
|
|
4
|
+
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
|
|
5
|
+
# visit pages, interact with widgets and make assertions about page content.
|
|
6
|
+
#
|
|
7
|
+
# If you use these step definitions as basis for your features you will quickly end up
|
|
8
|
+
# with features that are:
|
|
9
|
+
#
|
|
10
|
+
# * Hard to maintain
|
|
11
|
+
# * Verbose to read
|
|
12
|
+
#
|
|
13
|
+
# A much better approach is to write your own higher level step definitions, following
|
|
14
|
+
# the advice in the following blog posts:
|
|
15
|
+
#
|
|
16
|
+
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
|
17
|
+
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
|
18
|
+
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'cucumber/rails'
|
|
22
|
+
|
|
23
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
|
24
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
|
25
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
|
26
|
+
# steps to use the XPath syntax.
|
|
27
|
+
Capybara.default_selector = :css
|
|
28
|
+
|
|
29
|
+
# By default, any exception happening in your Rails application will bubble up
|
|
30
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
|
31
|
+
# your application behaves in the production environment, where an error page will
|
|
32
|
+
# be rendered instead.
|
|
33
|
+
#
|
|
34
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
|
35
|
+
# exceptions and display an error page (just like when the app is running in production).
|
|
36
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
|
37
|
+
# There are two ways to allow Rails to rescue exceptions:
|
|
38
|
+
#
|
|
39
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
|
40
|
+
#
|
|
41
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
|
42
|
+
# recommended as it will mask a lot of errors for you!
|
|
43
|
+
#
|
|
44
|
+
ActionController::Base.allow_rescue = false
|
|
45
|
+
|
|
46
|
+
# Remove this line if your app doesn't have a database.
|
|
47
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
|
48
|
+
DatabaseCleaner.strategy = :transaction
|
|
49
|
+
|