blacklight 3.0pre1 → 3.0pre2
Sign up to get free protection for your applications and to get access to all the features.
- 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,121 @@
|
|
1
|
+
Feature: Search Filters
|
2
|
+
In order constrain searches
|
3
|
+
As a user
|
4
|
+
I want to filter search results via facets on the search page
|
5
|
+
|
6
|
+
Scenario: Filter a blank search
|
7
|
+
Given I am on the home page
|
8
|
+
When I follow "Tibetan"
|
9
|
+
Then I should see "Displaying all 6 items"
|
10
|
+
And I should see the applied facet "Language" with the value "Tibetan (6)"
|
11
|
+
When I follow "India"
|
12
|
+
Then I should see "Displaying all 2 items"
|
13
|
+
And I should see the applied facet "Language" with the value "Tibetan (2)"
|
14
|
+
And I should see the applied facet "Region" with the value "India (2)"
|
15
|
+
|
16
|
+
Scenario: Search with no filters applied
|
17
|
+
When I am on the home page
|
18
|
+
And I fill in "q" with "bod"
|
19
|
+
And I press "search"
|
20
|
+
Then I should be on "the catalog page"
|
21
|
+
And I should see "Displaying all 3 items"
|
22
|
+
And I should not see "No Keywords"
|
23
|
+
And I should see "You searched for:"
|
24
|
+
And I should see "All Fields"
|
25
|
+
And I should see "bod"
|
26
|
+
|
27
|
+
Scenario: Search with filters applied
|
28
|
+
When I am on the home page
|
29
|
+
And I fill in "q" with "history"
|
30
|
+
And I press "search"
|
31
|
+
Then I should be on "the catalog page"
|
32
|
+
And I should see "Displaying all 9 items"
|
33
|
+
And I should not see "No Keywords"
|
34
|
+
And I should see "You searched for:"
|
35
|
+
And I should see "All Fields"
|
36
|
+
And I should see "history"
|
37
|
+
When I follow "Tibetan"
|
38
|
+
Then I should see "Displaying all 2 items"
|
39
|
+
And I should see the applied facet "Language" with the value "Tibetan (2)"
|
40
|
+
And I should see "All Fields"
|
41
|
+
And I should see "history"
|
42
|
+
When I follow "2004"
|
43
|
+
Then I should see "Displaying 1 item"
|
44
|
+
And I should see "You searched for:"
|
45
|
+
And I should see the applied facet "Language" with the value "Tibetan (1)"
|
46
|
+
And I should see the applied facet "Publication Year" with the value "2004 (1)"
|
47
|
+
|
48
|
+
Scenario: Apply and remove filters
|
49
|
+
Given I am on the home page
|
50
|
+
When I follow "Tibetan"
|
51
|
+
And I should see "Language"
|
52
|
+
And I should see "Tibetan (6)"
|
53
|
+
And I should see "[remove]"
|
54
|
+
When I follow "remove"
|
55
|
+
Then I should not see "You searched for:"
|
56
|
+
And I should not see "Language: Tibetan [remove]"
|
57
|
+
And I should see "Welcome!"
|
58
|
+
|
59
|
+
Scenario: Changing search term should retain filters
|
60
|
+
When I am on the home page
|
61
|
+
And I fill in "q" with "history"
|
62
|
+
And I press "search"
|
63
|
+
Then I should be on "the catalog page"
|
64
|
+
And I should see "You searched for:"
|
65
|
+
And I should see "history"
|
66
|
+
When I follow "Tibetan"
|
67
|
+
Then I should see "You searched for:"
|
68
|
+
And I should see "history"
|
69
|
+
And I should see the applied facet "Language" with the value "Tibetan (2)"
|
70
|
+
When I follow "2004"
|
71
|
+
And I should see "You searched for:"
|
72
|
+
And I should see "history"
|
73
|
+
And I should see the applied facet "Language" with the value "Tibetan (1)"
|
74
|
+
And I should see the applied facet "Publication Year" with the value "2004 (1)"
|
75
|
+
When I fill in "q" with "china"
|
76
|
+
And I press "search"
|
77
|
+
Then I should be on "the catalog page"
|
78
|
+
And I should see "All Fields"
|
79
|
+
And I should see "china"
|
80
|
+
And I should see the applied facet "Language" with the value "Tibetan (1)"
|
81
|
+
And I should see the applied facet "Publication Year" with the value "2004 (1)"
|
82
|
+
|
83
|
+
|
84
|
+
Scenario: Sorting results should retain filters
|
85
|
+
When I am on the home page
|
86
|
+
And I fill in "q" with "history"
|
87
|
+
And I press "search"
|
88
|
+
Then I should be on "the catalog page"
|
89
|
+
And I should see "You searched for:"
|
90
|
+
And I should see "history"
|
91
|
+
When I follow "Tibetan"
|
92
|
+
And I should see "You searched for:"
|
93
|
+
And I should see "history"
|
94
|
+
And I should see the applied facet "Language" with the value "Tibetan (2)"
|
95
|
+
When I select "title" from "sort"
|
96
|
+
And I press "sort results"
|
97
|
+
Then I should be on "the catalog page"
|
98
|
+
And I should see "You searched for:"
|
99
|
+
And I should see "history"
|
100
|
+
And I should see the applied facet "Language" with the value "Tibetan (2)"
|
101
|
+
|
102
|
+
|
103
|
+
Scenario: Changing per page number should retain filters
|
104
|
+
When I am on the home page
|
105
|
+
And I fill in "q" with "history"
|
106
|
+
And I press "search"
|
107
|
+
Then I should be on "the catalog page"
|
108
|
+
And I should see "You searched for:"
|
109
|
+
And I should see "history"
|
110
|
+
When I follow "Tibetan"
|
111
|
+
And I should see "You searched for:"
|
112
|
+
And I should see "All Fields"
|
113
|
+
And I should see "history"
|
114
|
+
And I should see the applied facet "Language" with the value "Tibetan (2)"
|
115
|
+
When I select "20" from "per_page"
|
116
|
+
And I press "update"
|
117
|
+
Then I should be on "the catalog page"
|
118
|
+
And I should see "You searched for:"
|
119
|
+
And I should see "history"
|
120
|
+
And I should see the applied facet "Language" with the value "Tibetan (2)"
|
121
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
@search_history
|
2
|
+
Feature: Search History Page
|
3
|
+
As a user
|
4
|
+
In order see searches I've used and reuse them
|
5
|
+
I want a page that shows my (unique) search history from this session
|
6
|
+
|
7
|
+
Scenario: Menu Link
|
8
|
+
When I am on the home page
|
9
|
+
Then I should see "Search History"
|
10
|
+
When I follow "Search History"
|
11
|
+
Then I should be on the search history page
|
12
|
+
And I should see a stylesheet
|
13
|
+
|
14
|
+
Scenario: Have No Searches
|
15
|
+
Given no previous searches
|
16
|
+
When I go to the search history page
|
17
|
+
Then I should see "You have no search history"
|
18
|
+
|
19
|
+
Scenario: Have Searches
|
20
|
+
Given I have done a search with term "book"
|
21
|
+
When I go to the search history page
|
22
|
+
Then I should see "Your recent searches"
|
23
|
+
And I should see "book"
|
24
|
+
And I should not see "dang"
|
25
|
+
Given I have done a search with term "dang"
|
26
|
+
When I go to the search history page
|
27
|
+
Then I should see "dang"
|
28
|
+
And I should see "book"
|
29
|
+
|
30
|
+
Scenario: Deleting a Search
|
31
|
+
Given I have done a search with term "book"
|
32
|
+
And I am on the search history page
|
33
|
+
Then I should see a "delete" button
|
34
|
+
And I should see "book"
|
35
|
+
When I press "delete"
|
36
|
+
Then I should see "Successfully removed that search history item."
|
37
|
+
Then I should not see "book"
|
38
|
+
|
39
|
+
Scenario: Clearing Search History
|
40
|
+
Given I have done a search with term "book"
|
41
|
+
And I have done a search with term "dang"
|
42
|
+
And I am on the search history page
|
43
|
+
Then I should see "Clear Search History"
|
44
|
+
When I follow "Clear Search History"
|
45
|
+
Then I should see "Cleared your search history."
|
46
|
+
And I should see "You have no search history"
|
47
|
+
Then I should not see "book"
|
48
|
+
And I should not see "dang"
|
49
|
+
|
50
|
+
Scenario: Saving a Search when logged in
|
51
|
+
Given I am logged in as "user1"
|
52
|
+
And I have done a search with term "book"
|
53
|
+
And I am on the search history page
|
54
|
+
Then I should see a "save" button
|
55
|
+
When I press "save"
|
56
|
+
Then I should see "Successfully saved your search."
|
57
|
+
And I should be on the search history page
|
58
|
+
And I should see a "forget" button
|
59
|
+
|
60
|
+
Scenario: Saving a Search when not logged in
|
61
|
+
Given I have done a search with term "book"
|
62
|
+
And I am on the search history page
|
63
|
+
Then I should see a "save" button
|
64
|
+
When I press "save"
|
65
|
+
Then I should see "Sign in"
|
66
|
+
|
67
|
+
Scenario: Un-Saving a Search when logged in
|
68
|
+
Given I am logged in as "user1"
|
69
|
+
And I have done a search with term "book"
|
70
|
+
And I am on the search history page
|
71
|
+
Then I should see a "save" button
|
72
|
+
When I press "save"
|
73
|
+
Then I should see "Successfully saved your search."
|
74
|
+
And I should be on the search history page
|
75
|
+
And I should see a "forget" button
|
76
|
+
When I press "forget"
|
77
|
+
Then I should see "Successfully removed that saved search."
|
78
|
+
And I should be on the search history page
|
79
|
+
And I should see a "save" button
|
80
|
+
|
81
|
+
Scenario: Visiting Search History with saved searches after logging out
|
82
|
+
Given I am logged in as "user1"
|
83
|
+
And I have done a search with term "book"
|
84
|
+
And I am on the search history page
|
85
|
+
Then I should see a "save" button
|
86
|
+
When I press "save"
|
87
|
+
Then I should see "Successfully saved your search."
|
88
|
+
And I should be on the search history page
|
89
|
+
And I should see a "forget" button
|
90
|
+
When I follow "Log Out"
|
91
|
+
Then I should see "Login"
|
92
|
+
And I should not see "user1"
|
93
|
+
When I follow "Search History"
|
94
|
+
Then I should not see "book"
|
95
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
@search
|
2
|
+
Feature: Search Results
|
3
|
+
In order to find documents
|
4
|
+
As a user
|
5
|
+
I want to enter terms, select fields, and select number of results per page
|
6
|
+
|
7
|
+
Scenario: Empty query
|
8
|
+
Given I am on the catalog page
|
9
|
+
When I fill in the search box with ""
|
10
|
+
And I press "search"
|
11
|
+
Then I should get at least 30 results
|
12
|
+
And I should get exactly 30 results
|
13
|
+
And I should get at most 30 results
|
14
|
+
And I should get id "00282214" in the results
|
15
|
+
And I should have more results than a search for "korea"
|
16
|
+
|
17
|
+
Scenario: "inmul" query
|
18
|
+
Given I am on the catalog page
|
19
|
+
When I fill in the search box with "inmul"
|
20
|
+
And I press "search"
|
21
|
+
Then I should get exactly 1 result
|
22
|
+
And I should get id "77826928" in the results
|
23
|
+
And I should not get id "00282214" in the results
|
24
|
+
And I should have fewer results than a search for ""
|
25
|
+
|
26
|
+
Scenario: Diacritics stripping
|
27
|
+
Given I am on the catalog page
|
28
|
+
When I fill in the search box with "inmül"
|
29
|
+
And I press "search"
|
30
|
+
Then I should have the same number of results as a search for "inmul"
|
31
|
+
|
32
|
+
|
33
|
+
Scenario: case-insensitive
|
34
|
+
Given I am on the catalog page
|
35
|
+
When I fill in the search box with "inmul"
|
36
|
+
And I press "search"
|
37
|
+
Then I should have the same number of results as a search for "INMUL"
|
38
|
+
|
39
|
+
Scenario: Relevancy ordering
|
40
|
+
Given I am on the catalog page
|
41
|
+
When I fill in the search box with "Korea"
|
42
|
+
And I press "search"
|
43
|
+
Then I should get id "77826928" in the first 5 results
|
44
|
+
And I should get id "77826928" before id "94120425"
|
45
|
+
And I should get id "77826928" and id "94120425" no more than 5 positions from each other
|
46
|
+
|
47
|
+
Scenario: Excluded items
|
48
|
+
Given I am on the catalog page
|
49
|
+
When I fill in the search box with "Korea"
|
50
|
+
And I press "search"
|
51
|
+
Then I should not get id "94120425" in the first 1 result
|
52
|
+
|
53
|
+
Scenario: Top 5 results
|
54
|
+
Given I am on the catalog page
|
55
|
+
When I fill in the search box with "Korea"
|
56
|
+
And I press "search"
|
57
|
+
Then I should get at least 1 of these ids in the first 5 results: "77826928,94120425"
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
@search_sort
|
2
|
+
Feature: Search Sort
|
3
|
+
In order to sort searches
|
4
|
+
As a user
|
5
|
+
I want select a sort field and have the search results reordered by that field
|
6
|
+
|
7
|
+
Scenario: Sort on facet results with no search terms
|
8
|
+
Given I am on the home page
|
9
|
+
When I follow "English"
|
10
|
+
Then I should see "Sort by"
|
11
|
+
# 2009-08-25 I don't know why this isn't working ... Naomi.
|
12
|
+
# And I should see select list "select#sort" with "relevance" selected
|
13
|
+
When I select "title" from "sort"
|
14
|
+
And I press "sort results"
|
15
|
+
Then I should see "Sort by"
|
16
|
+
And I should see select list "select#sort" with "title" selected
|
17
|
+
|
18
|
+
Scenario: Sort on result set from fielded search
|
19
|
+
Given I am on the home page
|
20
|
+
And I fill in "q" with "bod"
|
21
|
+
And I select "Title" from "search_field"
|
22
|
+
And I press "search"
|
23
|
+
Then I should see "Sort by"
|
24
|
+
When I select "title" from "sort"
|
25
|
+
And I press "sort results"
|
26
|
+
Then I should see "Sort by"
|
27
|
+
And I should see select list "select#search_field" with "Title" selected
|
28
|
+
And I should see select list "select#sort" with "title" selected
|
29
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Then /^I should see an add to folder form$/ do
|
2
|
+
page.should have_selector("form.addFolder")
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should see a remove from folder form$/ do
|
6
|
+
page.should have_selector("form.deleteFolder")
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^I (add|remove) record (.+) (to|from) my folder$/ do |add_or_remove, id, wording|
|
10
|
+
click_button("folder_submit_#{id}")
|
11
|
+
end
|
12
|
+
|
13
|
+
Given /^I have record (.+) in my folder$/ do |arg1|
|
14
|
+
visit catalog_path(arg1)
|
15
|
+
click_button("Select")
|
16
|
+
click_link("Selected Items")
|
17
|
+
end
|
18
|
+
|
19
|
+
Then /^I (should|should not) see the Folder tools$/ do |comparator|
|
20
|
+
case comparator
|
21
|
+
when "should"
|
22
|
+
page.should have_selector("ul.folderTools")
|
23
|
+
when "should not"
|
24
|
+
page.should_not have_selector("ul.folderTools")
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
When /^I follow "([^\"]*)" in "([^\"]*)"$/ do |link, scope|
|
2
|
+
within(scope) do
|
3
|
+
click_link(link)
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^I should see a stylesheet/ do
|
8
|
+
page.should have_selector("link[rel=stylesheet]")
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /I should see "(.*)" (at least|at most|exactly) (.*) times?$/i do |target, comparator, expected_num|
|
12
|
+
actual_num = page.split(target).length - 1
|
13
|
+
case comparator
|
14
|
+
when "at least"
|
15
|
+
actual_num.should >= expected_num.to_i
|
16
|
+
when "at most"
|
17
|
+
actual_num.should <= expected_num.to_i
|
18
|
+
when "exactly"
|
19
|
+
actual_num.should == expected_num.to_i
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /I should see a "(.*)" element with "(.*)" = "(.*)" (at least|at most|exactly) (.*) times?$/i do |target, type, selector,comparator, expected_num|
|
24
|
+
actual_num = page.all("#{target}[#{type}=\"#{selector}\"]").length
|
25
|
+
case comparator
|
26
|
+
when "at least"
|
27
|
+
actual_num.should >= expected_num.to_i
|
28
|
+
when "at most"
|
29
|
+
actual_num.should <= expected_num.to_i
|
30
|
+
when "exactly"
|
31
|
+
actual_num.should == expected_num.to_i
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Then /^I (should not|should) see an? "([^\"]*)" element with an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,elem,attribute,value|
|
36
|
+
if bool == "should not"
|
37
|
+
page.should_not have_selector("#{elem}[#{attribute}=#{value}]")
|
38
|
+
else
|
39
|
+
page.should have_selector("#{elem}[#{attribute}=#{value}]")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Then /^I (should not|should) see an? "([^\"]*)" element with an? "([^\"]*)" attribute of "([^\"]*)" and an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,elem,attribute,value,attribute2,value2|
|
44
|
+
if bool == "should not"
|
45
|
+
page.should_not have_selector("#{elem}[#{attribute}=#{value}][#{attribute2}=#{value2}]")
|
46
|
+
else
|
47
|
+
page.should have_selector("#{elem}[#{attribute}=#{value}][#{attribute2}=#{value2}]")
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Then /^I (should|should not) see an? "([^\"]*)" element containing "([^\"]*)"$/ do |bool,elem,content|
|
2
|
+
if bool == "should"
|
3
|
+
page.should have_xpath("//#{elem}[text()='#{content}']")
|
4
|
+
else
|
5
|
+
page.should have_no_xpath("//#{elem}[text()='#{content}']")
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I should see link rel=alternate tags/ do
|
10
|
+
page.should have_selector("link[rel=alternate]")
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Given /^I am logged in as "([^\"]*)"$/ do |login|
|
2
|
+
email = "#{login}@#{login}.com"
|
3
|
+
user = User.create(:login => login, :email => email, :password => "password", :password_confirmation => "password")
|
4
|
+
# visit user_sessions_path(:user_session => {:login => login, :password => "password"}), :post
|
5
|
+
# User.find(user.id).should_not be_nil
|
6
|
+
visit new_user_session_path
|
7
|
+
fill_in("user_email", :with => email)
|
8
|
+
fill_in("user_password", :with => "password")
|
9
|
+
click_button("user_submit")
|
10
|
+
# response.body.should =~ /Logged/m
|
11
|
+
Then 'I should see "Log Out"'
|
12
|
+
end
|
13
|
+
|
14
|
+
Given /^"([^\"]*)" has saved a search with term "([^\"]*)"$/ do |user, term|
|
15
|
+
user = User.find_by_email("#{user}@#{user}.com")
|
16
|
+
user.searches << Search.create(:query_params => {:q => term})
|
17
|
+
user.save!
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# deprecated
|
2
|
+
Then /^I should see the applied filter "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
|
3
|
+
page.should have_selector(".facet_limit") do |node|
|
4
|
+
node.should have_selector("h3", :content => filter)
|
5
|
+
node.should have_selector("span.selected", :content => text)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I should see the applied facet "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
|
10
|
+
page.should have_selector(".facet_limit") do |node|
|
11
|
+
node.should have_selector("h3", :content => filter)
|
12
|
+
node.should have_selector("span.selected", :content => text)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^I should see the facet "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
|
17
|
+
page.should have_selector(".facet_limit") do |node|
|
18
|
+
node.should have_selector("h3", :content => filter)
|
19
|
+
node.should have_selector("a.label", :content => text)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^the facet "([^\"]+)" should display$/ do |filter|
|
24
|
+
page.should have_selector(".facet_limit") do |node|
|
25
|
+
node.should have_selector("h3", :content => filter)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|