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,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Rails.application.config.secret_token = 'b0a71f62c3707fe6874a435909a597203110c418dc3022773b5131e2a26a99b304010089bd3ebb92e206b3b94a883aeefa571a8a52a45160f8663d163786610c'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Rails.application.config.session_store :cookie_store, :key => '_rails3_root_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rake db:sessions:create")
|
8
|
+
# Rails.application.config.session_store :active_record_store
|
@@ -1,6 +1,61 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
Rails3Root::Application.routes.draw do
|
2
|
+
resource :account
|
3
|
+
root :to => 'accounts#edit'
|
4
4
|
|
5
|
-
|
5
|
+
# The priority is based upon order of creation:
|
6
|
+
# first created -> highest priority.
|
7
|
+
|
8
|
+
# Sample of regular route:
|
9
|
+
# match 'products/:id' => 'catalog#view'
|
10
|
+
# Keep in mind you can assign values other than :controller and :action
|
11
|
+
|
12
|
+
# Sample of named route:
|
13
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
14
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
15
|
+
|
16
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
17
|
+
# resources :products
|
18
|
+
|
19
|
+
# Sample resource route with options:
|
20
|
+
# resources :products do
|
21
|
+
# member do
|
22
|
+
# get :short
|
23
|
+
# post :toggle
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# collection do
|
27
|
+
# get :sold
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
# Sample resource route with sub-resources:
|
32
|
+
# resources :products do
|
33
|
+
# resources :comments, :sales
|
34
|
+
# resource :seller
|
35
|
+
# end
|
36
|
+
|
37
|
+
# Sample resource route with more complex sub-resources
|
38
|
+
# resources :products do
|
39
|
+
# resources :comments
|
40
|
+
# resources :sales do
|
41
|
+
# get :recent, :on => :collection
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
|
45
|
+
# Sample resource route within a namespace:
|
46
|
+
# namespace :admin do
|
47
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
48
|
+
# # (app/controllers/admin/products_controller.rb)
|
49
|
+
# resources :products
|
50
|
+
# end
|
51
|
+
|
52
|
+
# You can have the root of your site routed with "root"
|
53
|
+
# just remember to delete public/index.html.
|
54
|
+
# root :to => "welcome#index"
|
55
|
+
|
56
|
+
# See how all your routes lay out with "rake routes"
|
57
|
+
|
58
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
59
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
60
|
+
# match ':controller(/:action(/:id(.:format)))'
|
6
61
|
end
|
@@ -1,14 +1,20 @@
|
|
1
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
|
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
4
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
5
|
# files.
|
6
6
|
|
7
7
|
|
8
|
+
require 'uri'
|
9
|
+
require 'cgi'
|
8
10
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
module WithinHelpers
|
13
|
+
def with_scope(locator)
|
14
|
+
locator ? within(locator) { yield } : yield
|
15
|
+
end
|
16
|
+
end
|
17
|
+
World(WithinHelpers)
|
12
18
|
|
13
19
|
Given /^(?:|I )am on (.+)$/ do |page_name|
|
14
20
|
visit path_to(page_name)
|
@@ -18,24 +24,28 @@ When /^(?:|I )go to (.+)$/ do |page_name|
|
|
18
24
|
visit path_to(page_name)
|
19
25
|
end
|
20
26
|
|
21
|
-
When /^(?:|I )press "([
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
When /^(?:|I )follow "([^\"]*)"$/ do |link|
|
26
|
-
click_link(link)
|
27
|
+
When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
|
28
|
+
with_scope(selector) do
|
29
|
+
click_button(button)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
|
-
When /^(?:|I )follow "([
|
30
|
-
|
33
|
+
When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
|
34
|
+
with_scope(selector) do
|
35
|
+
click_link(link)
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
|
-
When /^(?:|I )fill in "([
|
34
|
-
|
39
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
|
40
|
+
with_scope(selector) do
|
41
|
+
fill_in(field, :with => value)
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
|
-
When /^(?:|I )fill in "([
|
38
|
-
|
45
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
46
|
+
with_scope(selector) do
|
47
|
+
fill_in(field, :with => value)
|
48
|
+
end
|
39
49
|
end
|
40
50
|
|
41
51
|
# Use this to fill in an entire form with data from a table. Example:
|
@@ -49,211 +59,161 @@ end
|
|
49
59
|
# TODO: Add support for checkbox, select og option
|
50
60
|
# based on naming conventions.
|
51
61
|
#
|
52
|
-
When /^(?:|I )fill in the following
|
53
|
-
|
54
|
-
|
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
|
55
67
|
end
|
56
68
|
end
|
57
69
|
|
58
|
-
When /^(?:|I )select "([
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
63
|
-
# When I select "December 25, 2008 10:00" as the date and time
|
64
|
-
When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
|
65
|
-
select_datetime(time)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Use this step when using multiple datetime_select helpers on a page or
|
69
|
-
# you want to specify which datetime to select. Given the following view:
|
70
|
-
# <%= f.label :preferred %><br />
|
71
|
-
# <%= f.datetime_select :preferred %>
|
72
|
-
# <%= f.label :alternative %><br />
|
73
|
-
# <%= f.datetime_select :alternative %>
|
74
|
-
# The following steps would fill out the form:
|
75
|
-
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
76
|
-
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
77
|
-
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
78
|
-
select_datetime(datetime, :from => datetime_label)
|
79
|
-
end
|
80
|
-
|
81
|
-
# Use this step in conjunction with Rail's time_select helper. For example:
|
82
|
-
# When I select "2:20PM" as the time
|
83
|
-
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
84
|
-
# will convert the 2:20PM to 14:20 and then select it.
|
85
|
-
When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
|
86
|
-
select_time(time)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Use this step when using multiple time_select helpers on a page or you want to
|
90
|
-
# specify the name of the time on the form. For example:
|
91
|
-
# When I select "7:30AM" as the "Gym" time
|
92
|
-
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
93
|
-
select_time(time, :from => time_label)
|
94
|
-
end
|
95
|
-
|
96
|
-
# Use this step in conjunction with Rail's date_select helper. For example:
|
97
|
-
# When I select "February 20, 1981" as the date
|
98
|
-
When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
|
99
|
-
select_date(date)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Use this step when using multiple date_select helpers on one page or
|
103
|
-
# you want to specify the name of the date on the form. For example:
|
104
|
-
# When I select "April 26, 1982" as the "Date of Birth" date
|
105
|
-
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
106
|
-
select_date(date, :from => date_label)
|
70
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
|
71
|
+
with_scope(selector) do
|
72
|
+
select(value, :from => field)
|
73
|
+
end
|
107
74
|
end
|
108
75
|
|
109
|
-
When /^(?:|I )check "([
|
110
|
-
|
76
|
+
When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
77
|
+
with_scope(selector) do
|
78
|
+
check(field)
|
79
|
+
end
|
111
80
|
end
|
112
81
|
|
113
|
-
When /^(?:|I )uncheck "([
|
114
|
-
|
82
|
+
When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
83
|
+
with_scope(selector) do
|
84
|
+
uncheck(field)
|
85
|
+
end
|
115
86
|
end
|
116
87
|
|
117
|
-
When /^(?:|I )choose "([
|
118
|
-
|
88
|
+
When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
|
89
|
+
with_scope(selector) do
|
90
|
+
choose(field)
|
91
|
+
end
|
119
92
|
end
|
120
93
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
125
|
-
type = path.split(".")[1]
|
126
|
-
|
127
|
-
case type
|
128
|
-
when "jpg"
|
129
|
-
type = "image/jpg"
|
130
|
-
when "jpeg"
|
131
|
-
type = "image/jpeg"
|
132
|
-
when "png"
|
133
|
-
type = "image/png"
|
134
|
-
when "gif"
|
135
|
-
type = "image/gif"
|
94
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
|
95
|
+
with_scope(selector) do
|
96
|
+
attach_file(field, path)
|
136
97
|
end
|
137
|
-
|
138
|
-
attach_file(field, path, type)
|
139
98
|
end
|
140
99
|
|
141
|
-
Then /^(?:|I )should see
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
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
|
147
105
|
end
|
148
106
|
|
149
|
-
Then /^(?:|I )should see "([
|
150
|
-
|
151
|
-
if
|
152
|
-
|
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)
|
153
111
|
else
|
154
|
-
assert
|
112
|
+
assert page.has_content?(text)
|
155
113
|
end
|
156
114
|
end
|
157
115
|
end
|
158
116
|
|
159
|
-
Then /^(?:|I )should see \/([^\/]*)
|
117
|
+
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
160
118
|
regexp = Regexp.new(regexp)
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
assert_contain regexp
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
169
|
-
within(selector) do |content|
|
170
|
-
regexp = Regexp.new(regexp)
|
171
|
-
if defined?(Spec::Rails::Matchers)
|
172
|
-
content.should contain(regexp)
|
119
|
+
with_scope(selector) do
|
120
|
+
if page.respond_to? :should
|
121
|
+
page.should have_xpath('//*', :text => regexp)
|
173
122
|
else
|
174
|
-
assert
|
123
|
+
assert page.has_xpath?('//*', :text => regexp)
|
175
124
|
end
|
176
125
|
end
|
177
126
|
end
|
178
127
|
|
179
|
-
Then /^(?:|I )should not see "([
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
assert_not_contain text
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
188
|
-
within(selector) do |content|
|
189
|
-
if defined?(Spec::Rails::Matchers)
|
190
|
-
content.should_not contain(text)
|
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)
|
191
132
|
else
|
192
|
-
|
133
|
+
assert page.has_no_content?(text)
|
193
134
|
end
|
194
135
|
end
|
195
136
|
end
|
196
137
|
|
197
|
-
Then /^(?:|I )should not see \/([^\/]*)
|
138
|
+
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
198
139
|
regexp = Regexp.new(regexp)
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
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
|
203
146
|
end
|
204
147
|
end
|
205
148
|
|
206
|
-
Then /^(
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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}/
|
211
155
|
else
|
212
|
-
|
156
|
+
assert_match(/#{value}/, field_value)
|
213
157
|
end
|
214
158
|
end
|
215
159
|
end
|
216
160
|
|
217
|
-
Then /^the "([
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
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
|
222
170
|
end
|
223
171
|
end
|
224
172
|
|
225
|
-
Then /^the "([
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
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
|
230
181
|
end
|
231
182
|
end
|
232
183
|
|
233
|
-
Then /^the "([
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
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
|
238
192
|
end
|
239
193
|
end
|
240
|
-
|
241
|
-
Then /^
|
242
|
-
|
243
|
-
|
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)
|
244
199
|
else
|
245
|
-
|
200
|
+
assert_equal path_to(page_name), current_path
|
246
201
|
end
|
247
202
|
end
|
248
203
|
|
249
|
-
Then /^(?:|I )should
|
250
|
-
|
251
|
-
|
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
|
252
212
|
else
|
253
|
-
assert_equal
|
213
|
+
assert_equal expected_params, actual_params
|
254
214
|
end
|
255
215
|
end
|
256
216
|
|
257
217
|
Then /^show me the page$/ do
|
258
218
|
save_and_open_page
|
259
|
-
end
|
219
|
+
end
|