janova-clearance 0.8.8 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -2
- data/README.md +34 -35
- data/Rakefile +79 -33
- data/VERSION +1 -1
- data/app/controllers/clearance/confirmations_controller.rb +0 -2
- data/app/controllers/clearance/passwords_controller.rb +1 -2
- data/app/controllers/clearance/sessions_controller.rb +1 -2
- data/app/controllers/clearance/users_controller.rb +0 -1
- data/app/models/clearance_mailer.rb +4 -4
- data/app/views/passwords/edit.html.erb +1 -1
- data/app/views/passwords/new.html.erb +2 -2
- data/app/views/sessions/new.html.erb +1 -1
- data/app/views/users/_form.html.erb +1 -1
- data/app/views/users/new.html.erb +1 -1
- data/clearance.gemspec +207 -0
- data/config/routes.rb +23 -0
- data/cucumber.yml +4 -0
- data/{rails/init.rb → init.rb} +0 -0
- data/lib/clearance.rb +2 -1
- data/lib/clearance/authentication.rb +2 -2
- data/lib/clearance/configuration.rb +10 -3
- data/lib/clearance/engine.rb +10 -0
- data/{shoulda_macros/clearance.rb → lib/clearance/shoulda_macros.rb} +11 -23
- data/lib/clearance/user.rb +5 -6
- data/lib/rails/generators/clearance_features_generator.rb +20 -0
- data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/password_reset.feature +1 -1
- data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/sign_in.feature +0 -0
- data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/sign_out.feature +0 -0
- data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/sign_up.feature +0 -0
- data/lib/rails/generators/clearance_features_templates/features/step_definitions/clearance_steps.rb +138 -0
- data/lib/rails/generators/clearance_generator.rb +72 -0
- data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/README +0 -0
- data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/clearance.rb +0 -0
- data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/factories.rb +0 -0
- data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/migrations/create_users.rb +0 -1
- data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/migrations/update_users.rb +0 -1
- data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/user.rb +0 -0
- data/lib/rails/generators/clearance_views_generator.rb +14 -0
- data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/passwords/edit.html.erb +3 -3
- data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/passwords/new.html.erb +3 -3
- data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/sessions/new.html.erb +3 -3
- data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/users/_inputs.html.erb +1 -1
- data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/users/new.html.erb +2 -2
- data/spec/rails_root/Gemfile +15 -0
- data/spec/rails_root/README +244 -0
- data/spec/rails_root/Rakefile +10 -0
- data/spec/rails_root/app/controllers/accounts_controller.rb +10 -0
- data/spec/rails_root/app/controllers/application_controller.rb +6 -0
- data/spec/rails_root/app/helpers/application_helper.rb +2 -0
- data/spec/rails_root/app/models/user.rb +3 -0
- data/{generators/clearance_views/USAGE → spec/rails_root/app/views/accounts/edit.html.erb} +0 -0
- data/spec/rails_root/app/views/layouts/application.html.erb +24 -0
- data/spec/rails_root/config.ru +4 -0
- data/spec/rails_root/config/application.rb +46 -0
- data/spec/rails_root/config/boot.rb +6 -0
- data/spec/rails_root/config/cucumber.yml +8 -0
- data/spec/rails_root/config/database.yml +25 -0
- data/spec/rails_root/config/environment.rb +7 -0
- data/spec/rails_root/config/environments/development.rb +21 -0
- data/spec/rails_root/config/environments/production.rb +42 -0
- data/spec/rails_root/config/environments/test.rb +34 -0
- data/spec/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_root/config/initializers/clearance.rb +3 -0
- data/spec/rails_root/config/initializers/inflections.rb +10 -0
- data/spec/rails_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails_root/config/initializers/secret_token.rb +7 -0
- data/spec/rails_root/config/initializers/session_store.rb +8 -0
- data/spec/rails_root/config/locales/en.yml +5 -0
- data/spec/rails_root/config/routes.rb +61 -0
- data/spec/rails_root/db/schema.rb +29 -0
- data/spec/rails_root/doc/README_FOR_APP +2 -0
- data/spec/rails_root/features/password_reset.feature +33 -0
- data/spec/rails_root/features/sign_in.feature +35 -0
- data/spec/rails_root/features/sign_out.feature +15 -0
- data/spec/rails_root/features/sign_up.feature +45 -0
- data/{generators/clearance_features/templates → spec/rails_root}/features/step_definitions/clearance_steps.rb +18 -7
- data/spec/rails_root/features/step_definitions/web_steps.rb +219 -0
- data/spec/rails_root/features/support/env.rb +57 -0
- data/spec/rails_root/features/support/paths.rb +45 -0
- data/spec/rails_root/lib/tasks/cucumber.rake +53 -0
- data/spec/rails_root/public/404.html +26 -0
- data/spec/rails_root/public/422.html +26 -0
- data/spec/rails_root/public/500.html +26 -0
- data/spec/rails_root/public/favicon.ico +0 -0
- data/spec/rails_root/public/images/rails.png +0 -0
- data/spec/rails_root/public/javascripts/application.js +2 -0
- data/spec/rails_root/public/javascripts/controls.js +965 -0
- data/spec/rails_root/public/javascripts/dragdrop.js +974 -0
- data/spec/rails_root/public/javascripts/effects.js +1123 -0
- data/spec/rails_root/public/javascripts/prototype.js +4874 -0
- data/spec/rails_root/public/javascripts/rails.js +118 -0
- data/spec/rails_root/public/robots.txt +5 -0
- data/spec/rails_root/script/cucumber +10 -0
- data/spec/rails_root/script/rails +9 -0
- data/spec/rails_root/spec/factories/clearance.rb +13 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/MIT-LICENSE +20 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/README +13 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/Rakefile +10 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/init.rb +5 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/lib/action_view/helpers/dynamic_form.rb +300 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/lib/action_view/locale/en.yml +8 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb +42 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_test.rb +370 -0
- data/spec/rails_root/vendor/plugins/dynamic_form/test/test_helper.rb +9 -0
- data/test/controllers/confirmations_controller_test.rb +10 -7
- data/test/controllers/passwords_controller_test.rb +16 -20
- data/test/controllers/sessions_controller_test.rb +59 -20
- data/test/controllers/users_controller_test.rb +19 -16
- data/test/models/clearance_mailer_test.rb +2 -2
- data/test/models/user_test.rb +14 -13
- data/test/rails_root/Gemfile +17 -0
- data/test/rails_root/README +244 -0
- data/test/rails_root/Rakefile +10 -0
- data/test/rails_root/app/helpers/application_helper.rb +0 -3
- data/test/rails_root/app/models/user.rb +3 -0
- data/test/rails_root/app/views/accounts/edit.html.erb +0 -0
- data/test/rails_root/app/views/layouts/application.html.erb +24 -0
- data/test/rails_root/config.ru +4 -0
- data/test/rails_root/config/application.rb +46 -0
- data/test/rails_root/config/boot.rb +5 -109
- data/test/rails_root/config/cucumber.yml +8 -0
- data/test/rails_root/config/database.yml +25 -0
- data/test/rails_root/config/environment.rb +5 -15
- data/test/rails_root/config/environments/development.rb +16 -14
- data/test/rails_root/config/environments/production.rb +42 -1
- data/test/rails_root/config/environments/test.rb +34 -36
- data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_root/config/initializers/inflections.rb +1 -1
- data/test/rails_root/config/initializers/secret_token.rb +7 -0
- data/test/rails_root/config/initializers/session_store.rb +8 -0
- data/test/rails_root/config/locales/en.yml +5 -0
- data/test/rails_root/config/routes.rb +59 -4
- data/test/rails_root/doc/README_FOR_APP +2 -0
- data/test/rails_root/features/step_definitions/web_steps.rb +125 -165
- data/test/rails_root/features/support/env.rb +24 -14
- data/test/rails_root/features/support/paths.rb +45 -0
- data/test/rails_root/lib/tasks/cucumber.rake +53 -0
- data/test/rails_root/public/404.html +26 -0
- data/test/rails_root/public/422.html +26 -0
- data/test/rails_root/public/500.html +26 -0
- data/test/rails_root/public/favicon.ico +0 -0
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/javascripts/application.js +2 -0
- data/test/rails_root/public/javascripts/controls.js +965 -0
- data/test/rails_root/public/javascripts/dragdrop.js +974 -0
- data/test/rails_root/public/javascripts/effects.js +1123 -0
- data/test/rails_root/public/javascripts/prototype.js +4874 -0
- data/test/rails_root/public/javascripts/rails.js +118 -0
- data/test/rails_root/public/robots.txt +5 -0
- data/test/rails_root/script/cucumber +10 -0
- data/test/rails_root/script/rails +9 -0
- data/test/rails_root/test/factories/clearance.rb +13 -0
- data/test/rails_root/test/functional/accounts_controller_test.rb +0 -1
- data/test/rails_root/test/performance/browsing_test.rb +9 -0
- data/test/rails_root/test/test_helper.rb +13 -0
- data/test/rails_root/vendor/plugins/dynamic_form/MIT-LICENSE +20 -0
- data/test/rails_root/vendor/plugins/dynamic_form/README +13 -0
- data/test/rails_root/vendor/plugins/dynamic_form/Rakefile +10 -0
- data/test/rails_root/vendor/plugins/dynamic_form/init.rb +5 -0
- data/test/rails_root/vendor/plugins/dynamic_form/lib/action_view/helpers/dynamic_form.rb +300 -0
- data/test/rails_root/vendor/plugins/dynamic_form/lib/action_view/locale/en.yml +8 -0
- data/test/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb +42 -0
- data/test/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_test.rb +370 -0
- data/test/rails_root/vendor/plugins/dynamic_form/test/test_helper.rb +9 -0
- data/test/test_helper.rb +31 -2
- metadata +273 -61
- data/generators/clearance/USAGE +0 -1
- data/generators/clearance/clearance_generator.rb +0 -68
- data/generators/clearance/lib/insert_commands.rb +0 -33
- data/generators/clearance/lib/rake_commands.rb +0 -22
- data/generators/clearance_features/USAGE +0 -1
- data/generators/clearance_features/clearance_features_generator.rb +0 -19
- data/generators/clearance_features/templates/features/support/paths.rb +0 -23
- data/generators/clearance_views/clearance_views_generator.rb +0 -27
- data/lib/clearance/routes.rb +0 -49
- data/test/rails_root/app/helpers/confirmations_helper.rb +0 -2
- data/test/rails_root/app/helpers/passwords_helper.rb +0 -2
- data/test/rails_root/config/initializers/requires.rb +0 -13
- data/test/rails_root/config/initializers/time_formats.rb +0 -4
- data/test/rails_root/public/dispatch.rb +0 -10
- data/test/rails_root/script/create_project.rb +0 -52
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +0 -21
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/formtastic.rb +0 -1236
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/justin_french/formtastic.rb +0 -10
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/rails/init.rb +0 -3
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/formtastic_spec.rb +0 -2900
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/test_helper.rb +0 -14
@@ -0,0 +1,35 @@
|
|
1
|
+
Feature: Sign in
|
2
|
+
In order to get access to protected sections of the site
|
3
|
+
A user
|
4
|
+
Should be able to sign in
|
5
|
+
|
6
|
+
Scenario: User is not signed up
|
7
|
+
Given no user exists with an email of "email@person.com"
|
8
|
+
When I go to the sign in page
|
9
|
+
And I sign in as "email@person.com/password"
|
10
|
+
Then I should see "Bad email or password"
|
11
|
+
And I should be signed out
|
12
|
+
|
13
|
+
Scenario: User is not confirmed
|
14
|
+
Given I signed up with "email@person.com/password"
|
15
|
+
When I go to the sign in page
|
16
|
+
And I sign in as "email@person.com/password"
|
17
|
+
Then I should see "User has not confirmed email"
|
18
|
+
And I should be signed out
|
19
|
+
|
20
|
+
Scenario: User enters wrong password
|
21
|
+
Given I am signed up and confirmed as "email@person.com/password"
|
22
|
+
When I go to the sign in page
|
23
|
+
And I sign in as "email@person.com/wrongpassword"
|
24
|
+
Then I should see "Bad email or password"
|
25
|
+
And I should be signed out
|
26
|
+
|
27
|
+
Scenario: User signs in successfully
|
28
|
+
Given I am signed up and confirmed as "email@person.com/password"
|
29
|
+
When I go to the sign in page
|
30
|
+
And I sign in as "email@person.com/password"
|
31
|
+
Then I should see "Signed in"
|
32
|
+
And I should be signed in
|
33
|
+
When I return next time
|
34
|
+
Then I should be signed in
|
35
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Sign out
|
2
|
+
To protect my account from unauthorized access
|
3
|
+
A signed in user
|
4
|
+
Should be able to sign out
|
5
|
+
|
6
|
+
Scenario: User signs out
|
7
|
+
Given I am signed up and confirmed as "email@person.com/password"
|
8
|
+
When I sign in as "email@person.com/password"
|
9
|
+
Then I should be signed in
|
10
|
+
And I sign out
|
11
|
+
Then I should see "Signed out"
|
12
|
+
And I should be signed out
|
13
|
+
When I return next time
|
14
|
+
Then I should be signed out
|
15
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
Feature: Sign up
|
2
|
+
In order to get access to protected sections of the site
|
3
|
+
A user
|
4
|
+
Should be able to sign up
|
5
|
+
|
6
|
+
Scenario: User signs up with invalid data
|
7
|
+
When I go to the sign up page
|
8
|
+
And I fill in "Email" with "invalidemail"
|
9
|
+
And I fill in "Password" with "password"
|
10
|
+
And I fill in "Confirm password" with ""
|
11
|
+
And I press "Sign up"
|
12
|
+
Then I should see error messages
|
13
|
+
|
14
|
+
Scenario: User signs up with valid data
|
15
|
+
When I go to the sign up page
|
16
|
+
And I fill in "Email" with "email@person.com"
|
17
|
+
And I fill in "Password" with "password"
|
18
|
+
And I fill in "Confirm password" with "password"
|
19
|
+
And I press "Sign up"
|
20
|
+
Then I should see "instructions for confirming"
|
21
|
+
And a confirmation message should be sent to "email@person.com"
|
22
|
+
|
23
|
+
Scenario: User confirms his account
|
24
|
+
Given I signed up with "email@person.com/password"
|
25
|
+
When I follow the confirmation link sent to "email@person.com"
|
26
|
+
Then I should see "Confirmed email and signed in"
|
27
|
+
And I should be signed in
|
28
|
+
|
29
|
+
Scenario: Signed in user clicks confirmation link again
|
30
|
+
Given I signed up with "email@person.com/password"
|
31
|
+
When I follow the confirmation link sent to "email@person.com"
|
32
|
+
Then I should be signed in
|
33
|
+
When I follow the confirmation link sent to "email@person.com"
|
34
|
+
Then I should see "Confirmed email and signed in"
|
35
|
+
And I should be signed in
|
36
|
+
|
37
|
+
Scenario: Signed out user clicks confirmation link again
|
38
|
+
Given I signed up with "email@person.com/password"
|
39
|
+
When I follow the confirmation link sent to "email@person.com"
|
40
|
+
Then I should be signed in
|
41
|
+
When I sign out
|
42
|
+
And I follow the confirmation link sent to "email@person.com"
|
43
|
+
Then I should see "Already confirmed email. Please sign in."
|
44
|
+
And I should be signed out
|
45
|
+
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# General
|
2
2
|
|
3
3
|
Then /^I should see error messages$/ do
|
4
|
-
|
4
|
+
Then %{I should see "errors prohibited"}
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^I should see an error message$/ do
|
8
|
+
Then %{I should see "error prohibited"}
|
5
9
|
end
|
6
10
|
|
7
11
|
# Database
|
@@ -27,16 +31,20 @@ end
|
|
27
31
|
# Session
|
28
32
|
|
29
33
|
Then /^I should be signed in$/ do
|
30
|
-
|
34
|
+
Given %{I am on the homepage}
|
35
|
+
Then %{I should see "Sign out"}
|
31
36
|
end
|
32
37
|
|
33
38
|
Then /^I should be signed out$/ do
|
34
|
-
|
39
|
+
Given %{I am on the homepage}
|
40
|
+
Then %{I should see "Sign in"}
|
35
41
|
end
|
36
42
|
|
37
43
|
When /^session is cleared$/ do
|
38
|
-
|
39
|
-
|
44
|
+
# TODO: This doesn't work with Capybara
|
45
|
+
# TODO: I tried Capybara.reset_sessions! but that didn't work
|
46
|
+
#request.reset_session
|
47
|
+
#controller.instance_variable_set(:@_current_user, nil)
|
40
48
|
end
|
41
49
|
|
42
50
|
Given /^I have signed in with "(.*)\/(.*)"$/ do |email, password|
|
@@ -100,8 +108,11 @@ When /^I sign in as "(.*)\/(.*)"$/ do |email, password|
|
|
100
108
|
And %{I press "Sign in"}
|
101
109
|
end
|
102
110
|
|
103
|
-
When
|
104
|
-
|
111
|
+
When "I sign out" do
|
112
|
+
steps %{
|
113
|
+
When I go to the homepage
|
114
|
+
And I follow "Sign out"
|
115
|
+
}
|
105
116
|
end
|
106
117
|
|
107
118
|
When /^I request password reset link to be sent to "(.*)"$/ do |email|
|
@@ -0,0 +1,219 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
require 'uri'
|
9
|
+
require 'cgi'
|
10
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
11
|
+
|
12
|
+
module WithinHelpers
|
13
|
+
def with_scope(locator)
|
14
|
+
locator ? within(locator) { yield } : yield
|
15
|
+
end
|
16
|
+
end
|
17
|
+
World(WithinHelpers)
|
18
|
+
|
19
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
20
|
+
visit path_to(page_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
24
|
+
visit path_to(page_name)
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
|
28
|
+
with_scope(selector) do
|
29
|
+
click_button(button)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
|
34
|
+
with_scope(selector) do
|
35
|
+
click_link(link)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
|
40
|
+
with_scope(selector) do
|
41
|
+
fill_in(field, :with => value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
46
|
+
with_scope(selector) do
|
47
|
+
fill_in(field, :with => value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Use this to fill in an entire form with data from a table. Example:
|
52
|
+
#
|
53
|
+
# When I fill in the following:
|
54
|
+
# | Account Number | 5002 |
|
55
|
+
# | Expiry date | 2009-11-01 |
|
56
|
+
# | Note | Nice guy |
|
57
|
+
# | Wants Email? | |
|
58
|
+
#
|
59
|
+
# TODO: Add support for checkbox, select og option
|
60
|
+
# based on naming conventions.
|
61
|
+
#
|
62
|
+
When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
|
63
|
+
with_scope(selector) do
|
64
|
+
fields.rows_hash.each do |name, value|
|
65
|
+
When %{I fill in "#{name}" with "#{value}"}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
71
|
+
with_scope(selector) do
|
72
|
+
select(value, :from => field)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
77
|
+
with_scope(selector) do
|
78
|
+
check(field)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
83
|
+
with_scope(selector) do
|
84
|
+
uncheck(field)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
89
|
+
with_scope(selector) do
|
90
|
+
choose(field)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
|
95
|
+
with_scope(selector) do
|
96
|
+
attach_file(field, path)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
Then /^(?:|I )should see JSON:$/ do |expected_json|
|
101
|
+
require 'json'
|
102
|
+
expected = JSON.pretty_generate(JSON.parse(expected_json))
|
103
|
+
actual = JSON.pretty_generate(JSON.parse(response.body))
|
104
|
+
expected.should == actual
|
105
|
+
end
|
106
|
+
|
107
|
+
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
108
|
+
with_scope(selector) do
|
109
|
+
if page.respond_to? :should
|
110
|
+
page.should have_content(text)
|
111
|
+
else
|
112
|
+
assert page.has_content?(text)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
118
|
+
regexp = Regexp.new(regexp)
|
119
|
+
with_scope(selector) do
|
120
|
+
if page.respond_to? :should
|
121
|
+
page.should have_xpath('//*', :text => regexp)
|
122
|
+
else
|
123
|
+
assert page.has_xpath?('//*', :text => regexp)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
129
|
+
with_scope(selector) do
|
130
|
+
if page.respond_to? :should
|
131
|
+
page.should have_no_content(text)
|
132
|
+
else
|
133
|
+
assert page.has_no_content?(text)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
139
|
+
regexp = Regexp.new(regexp)
|
140
|
+
with_scope(selector) do
|
141
|
+
if page.respond_to? :should
|
142
|
+
page.should have_no_xpath('//*', :text => regexp)
|
143
|
+
else
|
144
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
|
150
|
+
with_scope(selector) do
|
151
|
+
field = find_field(field)
|
152
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
153
|
+
if field_value.respond_to? :should
|
154
|
+
field_value.should =~ /#{value}/
|
155
|
+
else
|
156
|
+
assert_match(/#{value}/, field_value)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
|
162
|
+
with_scope(selector) do
|
163
|
+
field = find_field(field)
|
164
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
165
|
+
if field_value.respond_to? :should_not
|
166
|
+
field_value.should_not =~ /#{value}/
|
167
|
+
else
|
168
|
+
assert_no_match(/#{value}/, field_value)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
|
174
|
+
with_scope(selector) do
|
175
|
+
field_checked = find_field(label)['checked']
|
176
|
+
if field_checked.respond_to? :should
|
177
|
+
field_checked.should be_true
|
178
|
+
else
|
179
|
+
assert field_checked
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
|
185
|
+
with_scope(selector) do
|
186
|
+
field_checked = find_field(label)['checked']
|
187
|
+
if field_checked.respond_to? :should
|
188
|
+
field_checked.should be_false
|
189
|
+
else
|
190
|
+
assert !field_checked
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
196
|
+
current_path = URI.parse(current_url).path
|
197
|
+
if current_path.respond_to? :should
|
198
|
+
current_path.should == path_to(page_name)
|
199
|
+
else
|
200
|
+
assert_equal path_to(page_name), current_path
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
205
|
+
query = URI.parse(current_url).query
|
206
|
+
actual_params = query ? CGI.parse(query) : {}
|
207
|
+
expected_params = {}
|
208
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
209
|
+
|
210
|
+
if actual_params.respond_to? :should
|
211
|
+
actual_params.should == expected_params
|
212
|
+
else
|
213
|
+
assert_equal expected_params, actual_params
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
Then /^show me the page$/ do
|
218
|
+
save_and_open_page
|
219
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
ENV["RAILS_ENV"] ||= "test"
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
9
|
+
|
10
|
+
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
11
|
+
require 'cucumber/rails/world'
|
12
|
+
require 'cucumber/rails/active_record'
|
13
|
+
require 'cucumber/web/tableish'
|
14
|
+
|
15
|
+
require 'capybara/rails'
|
16
|
+
require 'capybara/cucumber'
|
17
|
+
require 'capybara/session'
|
18
|
+
require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
|
19
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
20
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
21
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
22
|
+
# steps to use the XPath syntax.
|
23
|
+
Capybara.default_selector = :css
|
24
|
+
|
25
|
+
# If you set this to false, any error raised from within your app will bubble
|
26
|
+
# up to your step definition and out to cucumber unless you catch it somewhere
|
27
|
+
# on the way. You can make Rails rescue errors and render error pages on a
|
28
|
+
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
29
|
+
#
|
30
|
+
# If you set this to true, Rails will rescue all errors and render error
|
31
|
+
# pages, more or less in the same way your application would behave in the
|
32
|
+
# default production environment. It's not recommended to do this for all
|
33
|
+
# of your scenarios, as this makes it hard to discover errors in your application.
|
34
|
+
ActionController::Base.allow_rescue = false
|
35
|
+
|
36
|
+
# If you set this to true, each scenario will run in a database transaction.
|
37
|
+
# You can still turn off transactions on a per-scenario basis, simply tagging
|
38
|
+
# a feature or scenario with the @no-txn tag. If you are using Capybara,
|
39
|
+
# tagging with @culerity or @javascript will also turn transactions off.
|
40
|
+
#
|
41
|
+
# If you set this to false, transactions will be off for all scenarios,
|
42
|
+
# regardless of whether you use @no-txn or not.
|
43
|
+
#
|
44
|
+
# Beware that turning transactions off will leave data in your database
|
45
|
+
# after each scenario, which can lead to hard-to-debug failures in
|
46
|
+
# subsequent scenarios. If you do this, we recommend you create a Before
|
47
|
+
# block that will explicitly put your database in a known state.
|
48
|
+
Cucumber::Rails::World.use_transactional_fixtures = true
|
49
|
+
# How to clean your database when transactions are turned off. See
|
50
|
+
# http://github.com/bmabey/database_cleaner for more info.
|
51
|
+
if defined?(ActiveRecord::Base)
|
52
|
+
begin
|
53
|
+
require 'database_cleaner'
|
54
|
+
DatabaseCleaner.strategy = :truncation
|
55
|
+
rescue LoadError => ignore_if_database_cleaner_not_present
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in web_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /the home\s?page/
|
12
|
+
'/'
|
13
|
+
|
14
|
+
# Add more mappings here.
|
15
|
+
when /the sign up page/i
|
16
|
+
sign_up_path
|
17
|
+
when /the sign in page/i
|
18
|
+
sign_in_path
|
19
|
+
when /the password reset request page/i
|
20
|
+
new_password_path
|
21
|
+
when /the sign up page/i
|
22
|
+
sign_up_path
|
23
|
+
when /the sign in page/i
|
24
|
+
sign_in_path
|
25
|
+
when /the password reset request page/i
|
26
|
+
new_password_path
|
27
|
+
# Here is an example that pulls values out of the Regexp:
|
28
|
+
#
|
29
|
+
# when /^(.*)'s profile page$/i
|
30
|
+
# user_profile_path(User.find_by_login($1))
|
31
|
+
|
32
|
+
else
|
33
|
+
begin
|
34
|
+
page_name =~ /the (.*) page/
|
35
|
+
path_components = $1.split(/\s+/)
|
36
|
+
self.send(path_components.push('path').join('_').to_sym)
|
37
|
+
rescue Object => e
|
38
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
39
|
+
"Now, go and add a mapping in #{__FILE__}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
World(NavigationHelpers)
|