clearance 0.8.4 → 0.8.5

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.
Files changed (68) hide show
  1. data/CHANGELOG.textile +12 -1
  2. data/README.textile +27 -44
  3. data/Rakefile +20 -36
  4. data/VERSION +1 -0
  5. data/app/controllers/clearance/confirmations_controller.rb +1 -1
  6. data/app/controllers/clearance/passwords_controller.rb +2 -2
  7. data/app/controllers/clearance/sessions_controller.rb +3 -3
  8. data/app/controllers/clearance/users_controller.rb +1 -1
  9. data/app/models/clearance_mailer.rb +2 -4
  10. data/app/views/sessions/new.html.erb +1 -1
  11. data/generators/clearance/clearance_generator.rb +6 -0
  12. data/generators/clearance/lib/insert_commands.rb +1 -1
  13. data/generators/clearance/templates/README +13 -11
  14. data/generators/clearance/templates/clearance.rb +3 -0
  15. data/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb +12 -8
  16. data/generators/clearance_features/templates/features/support/paths.rb +10 -9
  17. data/generators/clearance_views/templates/formtastic/sessions/new.html.erb +1 -1
  18. data/lib/clearance.rb +2 -1
  19. data/lib/clearance/authentication.rb +2 -2
  20. data/lib/clearance/configuration.rb +25 -0
  21. data/lib/clearance/routes.rb +49 -0
  22. data/lib/clearance/user.rb +0 -18
  23. data/shoulda_macros/clearance.rb +1 -1
  24. data/test/controllers/confirmations_controller_test.rb +100 -0
  25. data/test/controllers/passwords_controller_test.rb +183 -0
  26. data/test/controllers/sessions_controller_test.rb +141 -0
  27. data/test/controllers/users_controller_test.rb +65 -0
  28. data/test/models/clearance_mailer_test.rb +55 -0
  29. data/test/models/user_test.rb +227 -0
  30. data/test/rails_root/app/controllers/accounts_controller.rb +10 -0
  31. data/test/rails_root/app/controllers/application_controller.rb +5 -0
  32. data/test/rails_root/app/helpers/application_helper.rb +5 -0
  33. data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
  34. data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
  35. data/test/rails_root/app/models/user.rb +3 -0
  36. data/test/rails_root/config/boot.rb +110 -0
  37. data/test/rails_root/config/environment.rb +17 -0
  38. data/test/rails_root/config/environments/development.rb +19 -0
  39. data/test/rails_root/config/environments/production.rb +1 -0
  40. data/test/rails_root/config/environments/test.rb +36 -0
  41. data/test/rails_root/config/initializers/clearance.rb +3 -0
  42. data/test/rails_root/config/initializers/clearance_loader.rb +8 -0
  43. data/test/rails_root/config/initializers/inflections.rb +10 -0
  44. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  45. data/test/rails_root/config/initializers/requires.rb +13 -0
  46. data/test/rails_root/config/initializers/time_formats.rb +4 -0
  47. data/test/rails_root/config/routes.rb +6 -0
  48. data/test/rails_root/db/migrate/20100120045223_clearance_create_users.rb +21 -0
  49. data/test/rails_root/features/step_definitions/clearance_steps.rb +122 -0
  50. data/test/rails_root/features/step_definitions/factory_girl_steps.rb +5 -0
  51. data/test/rails_root/features/step_definitions/web_steps.rb +259 -0
  52. data/test/rails_root/features/support/env.rb +47 -0
  53. data/test/rails_root/features/support/paths.rb +23 -0
  54. data/test/rails_root/public/dispatch.rb +10 -0
  55. data/test/rails_root/script/create_project.rb +52 -0
  56. data/test/rails_root/test/factories/clearance.rb +13 -0
  57. data/test/rails_root/test/functional/accounts_controller_test.rb +23 -0
  58. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +21 -0
  59. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/formtastic.rb +1236 -0
  60. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/justin_french/formtastic.rb +10 -0
  61. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/rails/init.rb +3 -0
  62. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/formtastic_spec.rb +2900 -0
  63. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/test_helper.rb +14 -0
  64. data/test/test_helper.rb +19 -0
  65. metadata +60 -18
  66. data/TODO.textile +0 -6
  67. data/config/clearance_routes.rb +0 -30
  68. data/lib/clearance/extensions/routes.rb +0 -14
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), 'boot')
2
+ require 'digest/md5'
3
+
4
+ Rails::Initializer.run do |config|
5
+ config.load_paths += Dir.glob(File.join(RAILS_ROOT, 'vendor', 'gems', '*', 'lib'))
6
+ config.time_zone = 'Eastern Time (US & Canada)'
7
+ config.action_controller.session = {
8
+ :session_key => "_clearance_session",
9
+ :secret => ['clearance', 'random', 'words', 'here'].map {|k| Digest::MD5.hexdigest(k) }.join
10
+ }
11
+
12
+ config.gem "justinfrench-formtastic",
13
+ :lib => 'formtastic',
14
+ :source => 'http://gems.github.com'
15
+
16
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
17
+ end
@@ -0,0 +1,19 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_controller.perform_caching = false
14
+ config.action_view.debug_rjs = true
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ HOST = "localhost"
@@ -0,0 +1 @@
1
+ HOST = "http://example.com"
@@ -0,0 +1,36 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Disable request forgery protection in test environment
17
+ config.action_controller.allow_forgery_protection = false
18
+
19
+ # Tell ActionMailer not to deliver emails to the real world.
20
+ # The :test delivery method accumulates sent emails in the
21
+ # ActionMailer::Base.deliveries array.
22
+ config.action_mailer.delivery_method = :test
23
+
24
+ config.gem 'shoulda',
25
+ :source => "http://gemcutter.org",
26
+ :version => '>= 2.9.1'
27
+ config.gem 'factory_girl',
28
+ :source => "http://gemcutter.org",
29
+ :version => '>= 1.2.3'
30
+
31
+ config.gem 'cucumber-rails',
32
+ :lib => false,
33
+ :version => '>= 0.2.2'
34
+ config.gem 'webrat',
35
+ :lib => false,
36
+ :version => '>= 0.6.0'
@@ -0,0 +1,3 @@
1
+ Clearance.configure do |config|
2
+ config.mailer_sender = 'donotreply@example.com'
3
+ end
@@ -0,0 +1,8 @@
1
+ # This simulates loading the clearance gem, but without relying on
2
+ # vendor/gems
3
+
4
+ clearance_path = File.join(File.dirname(__FILE__), *%w(.. .. .. ..))
5
+ clearance_lib_path = File.join(clearance_path, "lib")
6
+
7
+ $LOAD_PATH.unshift(clearance_lib_path)
8
+ load File.join(clearance_path, 'rails', 'init.rb')
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,13 @@
1
+ Dir[File.join(RAILS_ROOT, 'lib', 'extensions', '*.rb')].each do |f|
2
+ require f
3
+ end
4
+
5
+ Dir[File.join(RAILS_ROOT, 'lib', '*.rb')].each do |f|
6
+ require f
7
+ end
8
+
9
+ # Rails 2 doesn't like mocks
10
+
11
+ Dir[File.join(RAILS_ROOT, 'test', 'mocks', RAILS_ENV, '*.rb')].each do |f|
12
+ require f
13
+ end
@@ -0,0 +1,4 @@
1
+ # Example time formats
2
+ { :short_date => "%x", :long_date => "%a, %b %d, %Y" }.each do |k, v|
3
+ ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(k => v)
4
+ end
@@ -0,0 +1,6 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.resource :account
3
+ map.root :controller => 'accounts', :action => 'edit'
4
+
5
+ Clearance::Routes.draw(map)
6
+ end
@@ -0,0 +1,21 @@
1
+ class ClearanceCreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table(:users) do |t|
4
+ t.string :email
5
+ t.string :encrypted_password, :limit => 128
6
+ t.string :salt, :limit => 128
7
+ t.string :confirmation_token, :limit => 128
8
+ t.string :remember_token, :limit => 128
9
+ t.boolean :email_confirmed, :default => false, :null => false
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :users, [:id, :confirmation_token]
14
+ add_index :users, :email
15
+ add_index :users, :remember_token
16
+ end
17
+
18
+ def self.down
19
+ drop_table :users
20
+ end
21
+ end
@@ -0,0 +1,122 @@
1
+ # General
2
+
3
+ Then /^I should see error messages$/ do
4
+ assert_match /error(s)? prohibited/m, response.body
5
+ end
6
+
7
+ # Database
8
+
9
+ Given /^no user exists with an email of "(.*)"$/ do |email|
10
+ assert_nil User.find_by_email(email)
11
+ end
12
+
13
+ Given /^I signed up with "(.*)\/(.*)"$/ do |email, password|
14
+ user = Factory :user,
15
+ :email => email,
16
+ :password => password,
17
+ :password_confirmation => password
18
+ end
19
+
20
+ Given /^I am signed up and confirmed as "(.*)\/(.*)"$/ do |email, password|
21
+ user = Factory :email_confirmed_user,
22
+ :email => email,
23
+ :password => password,
24
+ :password_confirmation => password
25
+ end
26
+
27
+ # Session
28
+
29
+ Then /^I should be signed in$/ do
30
+ assert controller.signed_in?
31
+ end
32
+
33
+ Then /^I should be signed out$/ do
34
+ assert ! controller.signed_in?
35
+ end
36
+
37
+ When /^session is cleared$/ do
38
+ request.reset_session
39
+ controller.instance_variable_set(:@_current_user, nil)
40
+ end
41
+
42
+ Given /^I have signed in with "(.*)\/(.*)"$/ do |email, password|
43
+ Given %{I am signed up and confirmed as "#{email}/#{password}"}
44
+ And %{I sign in as "#{email}/#{password}"}
45
+ end
46
+
47
+ # Emails
48
+
49
+ Then /^a confirmation message should be sent to "(.*)"$/ do |email|
50
+ user = User.find_by_email(email)
51
+ assert !user.confirmation_token.blank?
52
+ assert !ActionMailer::Base.deliveries.empty?
53
+ result = ActionMailer::Base.deliveries.any? do |email|
54
+ email.to == [user.email] &&
55
+ email.subject =~ /confirm/i &&
56
+ email.body =~ /#{user.confirmation_token}/
57
+ end
58
+ assert result
59
+ end
60
+
61
+ When /^I follow the confirmation link sent to "(.*)"$/ do |email|
62
+ user = User.find_by_email(email)
63
+ visit new_user_confirmation_path(:user_id => user,
64
+ :token => user.confirmation_token)
65
+ end
66
+
67
+ Then /^a password reset message should be sent to "(.*)"$/ do |email|
68
+ user = User.find_by_email(email)
69
+ assert !user.confirmation_token.blank?
70
+ assert !ActionMailer::Base.deliveries.empty?
71
+ result = ActionMailer::Base.deliveries.any? do |email|
72
+ email.to == [user.email] &&
73
+ email.subject =~ /password/i &&
74
+ email.body =~ /#{user.confirmation_token}/
75
+ end
76
+ assert result
77
+ end
78
+
79
+ When /^I follow the password reset link sent to "(.*)"$/ do |email|
80
+ user = User.find_by_email(email)
81
+ visit edit_user_password_path(:user_id => user,
82
+ :token => user.confirmation_token)
83
+ end
84
+
85
+ When /^I try to change the password of "(.*)" without token$/ do |email|
86
+ user = User.find_by_email(email)
87
+ visit edit_user_password_path(:user_id => user)
88
+ end
89
+
90
+ Then /^I should be forbidden$/ do
91
+ assert_response :forbidden
92
+ end
93
+
94
+ # Actions
95
+
96
+ When /^I sign in as "(.*)\/(.*)"$/ do |email, password|
97
+ When %{I go to the sign in page}
98
+ And %{I fill in "Email" with "#{email}"}
99
+ And %{I fill in "Password" with "#{password}"}
100
+ And %{I press "Sign In"}
101
+ end
102
+
103
+ When /^I sign out$/ do
104
+ visit '/sign_out'
105
+ end
106
+
107
+ When /^I request password reset link to be sent to "(.*)"$/ do |email|
108
+ When %{I go to the password reset request page}
109
+ And %{I fill in "Email address" with "#{email}"}
110
+ And %{I press "Reset password"}
111
+ end
112
+
113
+ When /^I update my password with "(.*)\/(.*)"$/ do |password, confirmation|
114
+ And %{I fill in "Choose password" with "#{password}"}
115
+ And %{I fill in "Confirm password" with "#{confirmation}"}
116
+ And %{I press "Save this password"}
117
+ end
118
+
119
+ When /^I return next time$/ do
120
+ When %{session is cleared}
121
+ And %{I go to the homepage}
122
+ end
@@ -0,0 +1,5 @@
1
+ Factory.factories.each do |name, factory|
2
+ Given /^an? #{name} exists with an? (.*) of "([^"]*)"$/ do |attr, value|
3
+ Factory(name, attr.gsub(' ', '_') => value)
4
+ end
5
+ end
@@ -0,0 +1,259 @@
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 File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
9
+
10
+ # Commonly used webrat steps
11
+ # http://github.com/brynary/webrat
12
+
13
+ Given /^(?:|I )am on (.+)$/ do |page_name|
14
+ visit path_to(page_name)
15
+ end
16
+
17
+ When /^(?:|I )go to (.+)$/ do |page_name|
18
+ visit path_to(page_name)
19
+ end
20
+
21
+ When /^(?:|I )press "([^\"]*)"$/ do |button|
22
+ click_button(button)
23
+ end
24
+
25
+ When /^(?:|I )follow "([^\"]*)"$/ do |link|
26
+ click_link(link)
27
+ end
28
+
29
+ When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
30
+ click_link_within(parent, link)
31
+ end
32
+
33
+ When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
34
+ fill_in(field, :with => value)
35
+ end
36
+
37
+ When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
38
+ fill_in(field, :with => value)
39
+ end
40
+
41
+ # Use this to fill in an entire form with data from a table. Example:
42
+ #
43
+ # When I fill in the following:
44
+ # | Account Number | 5002 |
45
+ # | Expiry date | 2009-11-01 |
46
+ # | Note | Nice guy |
47
+ # | Wants Email? | |
48
+ #
49
+ # TODO: Add support for checkbox, select og option
50
+ # based on naming conventions.
51
+ #
52
+ When /^(?:|I )fill in the following:$/ do |fields|
53
+ fields.rows_hash.each do |name, value|
54
+ When %{I fill in "#{name}" with "#{value}"}
55
+ end
56
+ end
57
+
58
+ When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
59
+ select(value, :from => field)
60
+ end
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)
107
+ end
108
+
109
+ When /^(?:|I )check "([^\"]*)"$/ do |field|
110
+ check(field)
111
+ end
112
+
113
+ When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
114
+ uncheck(field)
115
+ end
116
+
117
+ When /^(?:|I )choose "([^\"]*)"$/ do |field|
118
+ choose(field)
119
+ end
120
+
121
+ # Adds support for validates_attachment_content_type. Without the mime-type getting
122
+ # passed to attach_file() you will get a "Photo file is not one of the allowed file types."
123
+ # error message
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"
136
+ end
137
+
138
+ attach_file(field, path, type)
139
+ end
140
+
141
+ Then /^(?:|I )should see "([^\"]*)"$/ do |text|
142
+ if defined?(Spec::Rails::Matchers)
143
+ response.should contain(text)
144
+ else
145
+ assert_contain text
146
+ end
147
+ end
148
+
149
+ Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
150
+ within(selector) do |content|
151
+ if defined?(Spec::Rails::Matchers)
152
+ content.should contain(text)
153
+ else
154
+ assert content.include?(text)
155
+ end
156
+ end
157
+ end
158
+
159
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
160
+ regexp = Regexp.new(regexp)
161
+ if defined?(Spec::Rails::Matchers)
162
+ response.should contain(regexp)
163
+ else
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)
173
+ else
174
+ assert content =~ regexp
175
+ end
176
+ end
177
+ end
178
+
179
+ Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
180
+ if defined?(Spec::Rails::Matchers)
181
+ response.should_not contain(text)
182
+ else
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)
191
+ else
192
+ assert !content.include?(text)
193
+ end
194
+ end
195
+ end
196
+
197
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
198
+ regexp = Regexp.new(regexp)
199
+ if defined?(Spec::Rails::Matchers)
200
+ response.should_not contain(regexp)
201
+ else
202
+ assert_not_contain regexp
203
+ end
204
+ end
205
+
206
+ Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
207
+ within(selector) do |content|
208
+ regexp = Regexp.new(regexp)
209
+ if defined?(Spec::Rails::Matchers)
210
+ content.should_not contain(regexp)
211
+ else
212
+ assert content !~ regexp
213
+ end
214
+ end
215
+ end
216
+
217
+ Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
218
+ if defined?(Spec::Rails::Matchers)
219
+ field_labeled(field).value.should =~ /#{value}/
220
+ else
221
+ assert_match(/#{value}/, field_labeled(field).value)
222
+ end
223
+ end
224
+
225
+ Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
226
+ if defined?(Spec::Rails::Matchers)
227
+ field_labeled(field).value.should_not =~ /#{value}/
228
+ else
229
+ assert_no_match(/#{value}/, field_labeled(field).value)
230
+ end
231
+ end
232
+
233
+ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
234
+ if defined?(Spec::Rails::Matchers)
235
+ field_labeled(label).should be_checked
236
+ else
237
+ assert field_labeled(label).checked?
238
+ end
239
+ end
240
+
241
+ Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
242
+ if defined?(Spec::Rails::Matchers)
243
+ field_labeled(label).should_not be_checked
244
+ else
245
+ assert !field_labeled(label).checked?
246
+ end
247
+ end
248
+
249
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
250
+ if defined?(Spec::Rails::Matchers)
251
+ URI.parse(current_url).path.should == path_to(page_name)
252
+ else
253
+ assert_equal path_to(page_name), URI.parse(current_url).path
254
+ end
255
+ end
256
+
257
+ Then /^show me the page$/ do
258
+ save_and_open_page
259
+ end