janova-clearance 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +278 -0
- data/LICENSE +21 -0
- data/README.md +129 -0
- data/Rakefile +87 -0
- data/VERSION +1 -0
- data/app/controllers/clearance/confirmations_controller.rb +76 -0
- data/app/controllers/clearance/passwords_controller.rb +85 -0
- data/app/controllers/clearance/sessions_controller.rb +67 -0
- data/app/controllers/clearance/users_controller.rb +35 -0
- data/app/models/clearance_mailer.rb +21 -0
- data/app/views/clearance_mailer/change_password.html.erb +9 -0
- data/app/views/clearance_mailer/confirmation.html.erb +5 -0
- data/app/views/passwords/edit.html.erb +23 -0
- data/app/views/passwords/new.html.erb +15 -0
- data/app/views/sessions/new.html.erb +24 -0
- data/app/views/users/_form.html.erb +13 -0
- data/app/views/users/new.html.erb +6 -0
- data/generators/clearance/USAGE +1 -0
- data/generators/clearance/clearance_generator.rb +68 -0
- data/generators/clearance/lib/insert_commands.rb +33 -0
- data/generators/clearance/lib/rake_commands.rb +22 -0
- data/generators/clearance/templates/README +24 -0
- data/generators/clearance/templates/clearance.rb +3 -0
- data/generators/clearance/templates/factories.rb +13 -0
- data/generators/clearance/templates/migrations/create_users.rb +21 -0
- data/generators/clearance/templates/migrations/update_users.rb +41 -0
- data/generators/clearance/templates/user.rb +3 -0
- data/generators/clearance_features/USAGE +1 -0
- data/generators/clearance_features/clearance_features_generator.rb +19 -0
- data/generators/clearance_features/templates/features/password_reset.feature +33 -0
- data/generators/clearance_features/templates/features/sign_in.feature +35 -0
- data/generators/clearance_features/templates/features/sign_out.feature +15 -0
- data/generators/clearance_features/templates/features/sign_up.feature +45 -0
- data/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb +122 -0
- data/generators/clearance_features/templates/features/support/paths.rb +23 -0
- data/generators/clearance_views/USAGE +0 -0
- data/generators/clearance_views/clearance_views_generator.rb +27 -0
- data/generators/clearance_views/templates/formtastic/passwords/edit.html.erb +21 -0
- data/generators/clearance_views/templates/formtastic/passwords/new.html.erb +15 -0
- data/generators/clearance_views/templates/formtastic/sessions/new.html.erb +21 -0
- data/generators/clearance_views/templates/formtastic/users/_inputs.html.erb +6 -0
- data/generators/clearance_views/templates/formtastic/users/new.html.erb +10 -0
- data/lib/clearance/authentication.rb +131 -0
- data/lib/clearance/configuration.rb +25 -0
- data/lib/clearance/extensions/errors.rb +6 -0
- data/lib/clearance/extensions/rescue.rb +5 -0
- data/lib/clearance/routes.rb +49 -0
- data/lib/clearance/user.rb +207 -0
- data/lib/clearance.rb +7 -0
- data/rails/init.rb +1 -0
- data/shoulda_macros/clearance.rb +266 -0
- data/test/controllers/confirmations_controller_test.rb +104 -0
- data/test/controllers/passwords_controller_test.rb +183 -0
- data/test/controllers/sessions_controller_test.rb +146 -0
- data/test/controllers/users_controller_test.rb +65 -0
- data/test/models/clearance_mailer_test.rb +55 -0
- data/test/models/user_test.rb +260 -0
- data/test/rails_root/app/controllers/accounts_controller.rb +10 -0
- data/test/rails_root/app/controllers/application_controller.rb +6 -0
- data/test/rails_root/app/helpers/application_helper.rb +5 -0
- data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
- data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
- data/test/rails_root/config/boot.rb +110 -0
- data/test/rails_root/config/environment.rb +17 -0
- data/test/rails_root/config/environments/development.rb +19 -0
- data/test/rails_root/config/environments/production.rb +1 -0
- data/test/rails_root/config/environments/test.rb +36 -0
- data/test/rails_root/config/initializers/clearance.rb +3 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/requires.rb +13 -0
- data/test/rails_root/config/initializers/time_formats.rb +4 -0
- data/test/rails_root/config/routes.rb +6 -0
- data/test/rails_root/features/step_definitions/web_steps.rb +259 -0
- data/test/rails_root/features/support/env.rb +47 -0
- data/test/rails_root/public/dispatch.rb +10 -0
- data/test/rails_root/script/create_project.rb +52 -0
- data/test/rails_root/test/functional/accounts_controller_test.rb +23 -0
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +21 -0
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/formtastic.rb +1236 -0
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/justin_french/formtastic.rb +10 -0
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/rails/init.rb +3 -0
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/formtastic_spec.rb +2900 -0
- data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/test_helper.rb +14 -0
- data/test/test_helper.rb +19 -0
- metadata +202 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
+
Rails::GemDependency.add_frozen_gem_path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class GemBoot < Boot
|
52
|
+
def load_initializer
|
53
|
+
self.class.load_rubygems
|
54
|
+
load_rails_gem
|
55
|
+
require 'initializer'
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_rails_gem
|
59
|
+
if version = self.class.gem_version
|
60
|
+
gem 'rails', version
|
61
|
+
else
|
62
|
+
gem 'rails'
|
63
|
+
end
|
64
|
+
rescue Gem::LoadError => load_error
|
65
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
|
69
|
+
class << self
|
70
|
+
def rubygems_version
|
71
|
+
Gem::RubyGemsVersion rescue nil
|
72
|
+
end
|
73
|
+
|
74
|
+
def gem_version
|
75
|
+
if defined? RAILS_GEM_VERSION
|
76
|
+
RAILS_GEM_VERSION
|
77
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
78
|
+
ENV['RAILS_GEM_VERSION']
|
79
|
+
else
|
80
|
+
parse_gem_version(read_environment_rb)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def load_rubygems
|
85
|
+
require 'rubygems'
|
86
|
+
min_version = '1.3.1'
|
87
|
+
unless rubygems_version >= min_version
|
88
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
89
|
+
exit 1
|
90
|
+
end
|
91
|
+
|
92
|
+
rescue LoadError
|
93
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_gem_version(text)
|
98
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def read_environment_rb
|
103
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# All that for this:
|
110
|
+
Rails.boot!
|
@@ -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,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,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,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
|