email_spec 1.6.0 → 2.0.0
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.
- checksums.yaml +7 -0
- data/History.txt +18 -0
- data/README.md +30 -28
- data/examples/rails4_root/Gemfile +19 -0
- data/examples/rails4_root/Gemfile.lock +180 -0
- data/examples/rails4_root/README +5 -0
- data/examples/rails4_root/Rakefile +11 -0
- data/examples/rails4_root/app/controllers/application_controller.rb +3 -0
- data/examples/rails4_root/app/controllers/welcome_controller.rb +18 -0
- data/examples/rails4_root/app/helpers/application_helper.rb +2 -0
- data/examples/rails4_root/app/mailers/user_mailer.rb +39 -0
- data/examples/rails4_root/app/models/user.rb +2 -0
- data/examples/rails4_root/app/views/user_mailer/email_with_attachment.html.erb +6 -0
- data/examples/rails4_root/app/views/user_mailer/newsletter.html.erb +8 -0
- data/examples/rails4_root/app/views/user_mailer/signup.html.erb +4 -0
- data/examples/rails4_root/app/views/user_mailer/signup.text.erb +4 -0
- data/examples/rails4_root/app/views/welcome/attachments.html.erb +0 -0
- data/examples/rails4_root/app/views/welcome/confirm.html.erb +1 -0
- data/examples/rails4_root/app/views/welcome/index.html.erb +8 -0
- data/examples/rails4_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails4_root/app/views/welcome/signup.html.erb +1 -0
- data/examples/rails4_root/attachments/document.pdf +0 -0
- data/examples/rails4_root/attachments/image.png +0 -0
- data/examples/rails4_root/config.ru +4 -0
- data/examples/rails4_root/config/application.rb +45 -0
- data/examples/rails4_root/config/boot.rb +14 -0
- data/examples/rails4_root/config/cucumber.yml +8 -0
- data/examples/rails4_root/config/database.yml +25 -0
- data/examples/rails4_root/config/environment.rb +6 -0
- data/examples/rails4_root/config/environments/development.rb +19 -0
- data/examples/rails4_root/config/environments/production.rb +42 -0
- data/examples/rails4_root/config/environments/test.rb +32 -0
- data/examples/rails4_root/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/rails4_root/config/initializers/cookie_verification_secret.rb +7 -0
- data/examples/rails4_root/config/initializers/delayed_job.rb +1 -0
- data/examples/rails4_root/config/initializers/inflections.rb +10 -0
- data/examples/rails4_root/config/initializers/mime_types.rb +5 -0
- data/examples/rails4_root/config/initializers/notifier_job.rb +1 -0
- data/examples/rails4_root/config/initializers/rspec_generator.rb +6 -0
- data/examples/rails4_root/config/initializers/session_store.rb +10 -0
- data/examples/rails4_root/config/locales/en.yml +5 -0
- data/examples/rails4_root/config/routes.rb +7 -0
- data/examples/rails4_root/config/secrets.yml +22 -0
- data/examples/rails4_root/db/migrate/20090125013728_create_users.rb +11 -0
- data/examples/rails4_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
- data/examples/rails4_root/db/migrate/20141119224309_add_queue_to_delayed_jobs.rb +9 -0
- data/examples/rails4_root/db/schema.rb +35 -0
- data/examples/rails4_root/db/seeds.rb +7 -0
- data/examples/rails4_root/db/test.sqlite3 +0 -0
- data/examples/rails4_root/doc/README_FOR_APP +2 -0
- data/examples/rails4_root/features/attachments.feature +27 -0
- data/examples/rails4_root/features/delayed_job.feature +13 -0
- data/examples/rails4_root/features/errors.feature +40 -0
- data/examples/rails4_root/features/example.feature +93 -0
- data/examples/rails4_root/features/step_definitions/email_steps.rb +210 -0
- data/examples/rails4_root/features/step_definitions/user_steps.rb +26 -0
- data/examples/rails4_root/features/step_definitions/web_steps.rb +219 -0
- data/examples/rails4_root/features/support/env.rb +59 -0
- data/examples/rails4_root/features/support/env_ext.rb +4 -0
- data/examples/rails4_root/features/support/paths.rb +33 -0
- data/examples/rails4_root/lib/notifier_job.rb +5 -0
- data/examples/rails4_root/lib/tasks/cucumber.rake +65 -0
- data/examples/rails4_root/lib/tasks/rspec.rake +69 -0
- data/examples/rails4_root/log/development.log +0 -0
- data/examples/rails4_root/log/test.log +43813 -0
- data/examples/rails4_root/public/404.html +26 -0
- data/examples/rails4_root/public/422.html +26 -0
- data/examples/rails4_root/public/500.html +26 -0
- data/examples/rails4_root/public/favicon.ico +0 -0
- data/examples/rails4_root/public/images/rails.png +0 -0
- data/examples/rails4_root/public/javascripts/application.js +2 -0
- data/examples/rails4_root/public/javascripts/controls.js +965 -0
- data/examples/rails4_root/public/javascripts/dragdrop.js +974 -0
- data/examples/rails4_root/public/javascripts/effects.js +1123 -0
- data/examples/rails4_root/public/javascripts/prototype.js +4874 -0
- data/examples/rails4_root/public/javascripts/rails.js +109 -0
- data/examples/rails4_root/public/robots.txt +5 -0
- data/examples/rails4_root/script/cucumber +10 -0
- data/examples/rails4_root/script/delayed_job +5 -0
- data/examples/rails4_root/script/rails +9 -0
- data/examples/rails4_root/spec/controllers/welcome_controller_spec.rb +20 -0
- data/examples/rails4_root/spec/models/user_mailer_spec.rb +47 -0
- data/examples/rails4_root/spec/spec_helper.rb +20 -0
- data/examples/rails4_root/test/mailers/user_mailer_classic_test.rb +27 -0
- data/examples/rails4_root/test/mailers/user_mailer_spec_test.rb +29 -0
- data/examples/rails4_root/test/test_helper.rb +10 -0
- data/{rails_generators → examples/rails4_root/vendor/plugins/email_spec/rails_generators}/email_spec/email_spec_generator.rb +0 -0
- data/{rails_generators → examples/rails4_root/vendor/plugins/email_spec/rails_generators}/email_spec/templates/email_steps.rb +22 -18
- data/examples/sinatra_root/Gemfile +15 -0
- data/examples/sinatra_root/Gemfile.lock +95 -0
- data/examples/sinatra_root/config.ru +4 -0
- data/examples/sinatra_root/features/errors.feature +40 -0
- data/examples/sinatra_root/features/example.feature +93 -0
- data/examples/sinatra_root/features/step_definitions/email_steps.rb +210 -0
- data/examples/sinatra_root/features/step_definitions/user_steps.rb +26 -0
- data/examples/sinatra_root/features/step_definitions/web_steps.rb +219 -0
- data/examples/sinatra_root/features/support/env.rb +21 -0
- data/examples/sinatra_root/features/support/paths.rb +29 -0
- data/examples/sinatra_root/lib/example_sinatra_app.rb +45 -0
- data/features/rails4_app.feature +32 -0
- data/features/sinatra_app.feature +14 -0
- data/features/step_definitions/app_steps.rb +58 -0
- data/features/support/env.rb +16 -0
- data/lib/email_spec.rb +1 -1
- data/lib/email_spec/deliveries.rb +0 -1
- data/lib/email_spec/email_viewer.rb +1 -1
- data/lib/email_spec/helpers.rb +16 -5
- data/lib/email_spec/matchers.rb +2 -1
- data/lib/email_spec/version.rb +3 -0
- data/lib/generators/email_spec/steps/templates/email_steps.rb +24 -20
- data/spec/email_spec/email_viewer_spec.rb +20 -0
- data/spec/email_spec/helpers_spec.rb +316 -0
- data/spec/email_spec/mail_ext_spec.rb +34 -0
- data/spec/email_spec/matchers_spec.rb +513 -0
- data/spec/spec_helper.rb +24 -0
- metadata +161 -150
- data/lib/email_spec/background_processes.rb +0 -45
- data/lib/generators/email_spec/steps/USAGE +0 -5
@@ -0,0 +1,26 @@
|
|
1
|
+
Given "I am a real person wanting to sign up for an account" do
|
2
|
+
# no-op.. for documentation purposes only!
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I submit my registration information$/ do
|
6
|
+
fill_in "Name", :with => 'Joe Someone'
|
7
|
+
fill_in "Email", :with => 'example@example.com'
|
8
|
+
click_button "Sign up"
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^(?:I|they) should receive an email with a link to a confirmation page$/ do
|
12
|
+
expect(unread_emails_for(current_email_address).size).to eql 1
|
13
|
+
|
14
|
+
# this call will store the email and you can access it with current_email
|
15
|
+
open_last_email_for(last_email_address)
|
16
|
+
expect(current_email).to have_subject(/Account confirmation/)
|
17
|
+
expect(current_email).to have_body_text('Joe Someone')
|
18
|
+
|
19
|
+
click_email_link_matching /confirm/
|
20
|
+
expect(page).to have_content("Confirm your new account")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Basically aliases "I should see [text]", but for third person
|
24
|
+
Then /^they should see "([^\"]*)"$/ do |text|
|
25
|
+
step "I should see \"#{text}\""
|
26
|
+
end
|
@@ -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
|
+
expect(expected).to eql actual
|
105
|
+
end
|
106
|
+
|
107
|
+
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
108
|
+
with_scope(selector) do
|
109
|
+
if self.respond_to? :expect
|
110
|
+
expect(page).to 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 self.respond_to? :expect
|
121
|
+
expect(page).to 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 self.respond_to? :expect
|
131
|
+
expect(page).to 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 self.respond_to? :expect
|
142
|
+
expect(page).to 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 self.respond_to? :expect
|
154
|
+
expect(field_value).to match /#{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 self.respond_to? :expect
|
166
|
+
expect(field_value).to_not match /#{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 self.respond_to? :expect
|
177
|
+
expect(field_checked).to 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 self.respond_to? :expect
|
188
|
+
expect(field_checked).to 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 self.respond_to? :expect
|
198
|
+
expect(current_path).to eql 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 self.respond_to? :expect
|
211
|
+
expect(actual_params).to eql 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,59 @@
|
|
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
|
+
require 'cucumber/rails'
|
8
|
+
|
9
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
10
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
11
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
12
|
+
# steps to use the XPath syntax.
|
13
|
+
Capybara.default_selector = :css
|
14
|
+
|
15
|
+
# By default, any exception happening in your Rails application will bubble up
|
16
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
17
|
+
# your application behaves in the production environment, where an error page will
|
18
|
+
# be rendered instead.
|
19
|
+
#
|
20
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
21
|
+
# exceptions and display an error page (just like when the app is running in production).
|
22
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
23
|
+
# There are two ways to allow Rails to rescue exceptions:
|
24
|
+
#
|
25
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
26
|
+
#
|
27
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
28
|
+
# recommended as it will mask a lot of errors for you!
|
29
|
+
#
|
30
|
+
ActionController::Base.allow_rescue = false
|
31
|
+
|
32
|
+
# Remove/comment out the lines below if your app doesn't have a database.
|
33
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
34
|
+
begin
|
35
|
+
DatabaseCleaner.strategy = :transaction
|
36
|
+
rescue NameError
|
37
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
38
|
+
end
|
39
|
+
|
40
|
+
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
41
|
+
# See the DatabaseCleaner documentation for details. Example:
|
42
|
+
#
|
43
|
+
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
44
|
+
# # { :except => [:widgets] } may not do what you expect here
|
45
|
+
# # as tCucumber::Rails::Database.javascript_strategy overrides
|
46
|
+
# # this setting.
|
47
|
+
# DatabaseCleaner.strategy = :truncation
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
51
|
+
# DatabaseCleaner.strategy = :transaction
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
|
55
|
+
# Possible values are :truncation and :transaction
|
56
|
+
# The :transaction strategy is faster, but might give you threading problems.
|
57
|
+
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
|
58
|
+
Cucumber::Rails::Database.javascript_strategy = :truncation
|
59
|
+
|
@@ -0,0 +1,33 @@
|
|
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
|
+
# Here is an example that pulls values out of the Regexp:
|
16
|
+
#
|
17
|
+
# when /^(.*)'s profile page$/i
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
19
|
+
|
20
|
+
when /request a newsletter/
|
21
|
+
request_newsletter_url('Name' => 'Joe Someone', 'Email' => 'example@example.com')
|
22
|
+
|
23
|
+
when /request attachments be sent to me/
|
24
|
+
request_attachments_url('Name' => 'Joe Someone', 'Email' => 'example@example.com')
|
25
|
+
|
26
|
+
else
|
27
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
28
|
+
"Now, go and add a mapping in #{__FILE__}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,65 @@
|
|
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
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
|
38
|
+
task :statsetup do
|
39
|
+
require 'rails/code_statistics'
|
40
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
41
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
desc 'Alias for cucumber:ok'
|
45
|
+
task :cucumber => 'cucumber:ok'
|
46
|
+
|
47
|
+
task :default => :cucumber
|
48
|
+
|
49
|
+
task :features => :cucumber do
|
50
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
51
|
+
end
|
52
|
+
|
53
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
54
|
+
task 'db:test:prepare' do
|
55
|
+
end
|
56
|
+
|
57
|
+
task :stats => 'cucumber:statsetup'
|
58
|
+
rescue LoadError
|
59
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
60
|
+
task :cucumber do
|
61
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
begin
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
rescue MissingSourceFile
|
5
|
+
module RSpec
|
6
|
+
module Core
|
7
|
+
class RakeTask
|
8
|
+
def initialize(name)
|
9
|
+
task name do
|
10
|
+
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
11
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
12
|
+
|
13
|
+
# ... otherwise, do this:
|
14
|
+
raise <<-MSG
|
15
|
+
|
16
|
+
#{"*" * 80}
|
17
|
+
* You are trying to run an rspec rake task defined in
|
18
|
+
* #{__FILE__},
|
19
|
+
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
20
|
+
#{"*" * 80}
|
21
|
+
MSG
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake.application.instance_variable_get('@tasks').delete('default')
|
30
|
+
|
31
|
+
spec_prereq = File.exist?(File.join(Rails.root, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
32
|
+
task :noop do
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :spec
|
36
|
+
task :stats => "spec:statsetup"
|
37
|
+
|
38
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
39
|
+
RSpec::Core::RakeTask.new(:spec => spec_prereq)
|
40
|
+
|
41
|
+
namespace :spec do
|
42
|
+
[:requests, :models, :controllers, :views, :helpers, :mailers, :lib].each do |sub|
|
43
|
+
desc "Run the code examples in spec/#{sub}"
|
44
|
+
RSpec::Core::RakeTask.new(sub => spec_prereq) do |t|
|
45
|
+
t.pattern = "./spec/#{sub}/**/*_spec.rb"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
task :statsetup do
|
50
|
+
require 'rails/code_statistics'
|
51
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
52
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
53
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
54
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
55
|
+
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
56
|
+
::STATS_DIRECTORIES << %w(Mailer\ specs spec/mailers) if File.exist?('spec/mailers')
|
57
|
+
::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
|
58
|
+
::STATS_DIRECTORIES << %w(Request\ specs spec/requests) if File.exist?('spec/requests')
|
59
|
+
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
60
|
+
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
61
|
+
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
62
|
+
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
63
|
+
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
64
|
+
::CodeStatistics::TEST_TYPES << "Mailer specs" if File.exist?('spec/mailer')
|
65
|
+
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
66
|
+
::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|