email_spec 0.5.0 → 0.6.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.
- data/History.txt +14 -2
- data/Rakefile +6 -4
- data/examples/rails_root/config/boot.rb +1 -1
- data/examples/rails_root/config/cucumber.yml +7 -0
- data/examples/rails_root/config/database.yml +4 -1
- data/examples/rails_root/config/environment.rb +6 -1
- data/examples/rails_root/config/environments/cucumber.rb +29 -0
- data/examples/rails_root/config/environments/production.rb +11 -7
- data/examples/rails_root/config/environments/test.rb +5 -8
- data/examples/rails_root/features/step_definitions/web_steps.rb +273 -0
- data/examples/rails_root/features/support/env.rb +48 -20
- data/examples/rails_root/features/support/env_ext.rb +6 -0
- data/examples/rails_root/features/support/paths.rb +8 -2
- data/examples/rails_root/lib/tasks/cucumber.rake +47 -0
- data/examples/rails_root/rerun.txt +1 -0
- data/examples/rails_root/script/cucumber +6 -5
- data/examples/sinatra/app.rb +1 -1
- data/examples/sinatra/features/step_definitions/web_steps.rb +273 -0
- data/examples/sinatra/features/support/env.rb +15 -9
- data/lib/email_spec/background_processes.rb +19 -5
- data/lib/email_spec/email_viewer.rb +18 -2
- data/rails_generators/email_spec/templates/email_steps.rb +31 -22
- metadata +9 -4
- data/examples/rails_root/features/step_definitions/webrat_steps.rb +0 -137
- data/examples/sinatra/features/step_definitions/webrat_steps.rb +0 -137
@@ -1,30 +1,58 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# Comment out the next line if you don't want Cucumber Unicode support
|
7
|
-
require 'cucumber/formatter/unicode'
|
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.
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
#Cucumber::Rails.use_transactional_fixtures
|
7
|
+
ENV["RAILS_ENV"] ||= "cucumber"
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
11
|
+
require 'cucumber/rails/rspec'
|
12
|
+
require 'cucumber/rails/world'
|
13
|
+
require 'cucumber/rails/active_record'
|
14
|
+
require 'cucumber/web/tableish'
|
16
15
|
|
17
16
|
require 'webrat'
|
17
|
+
require 'webrat/core/matchers'
|
18
|
+
|
18
19
|
Webrat.configure do |config|
|
19
20
|
config.mode = :rails
|
21
|
+
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
|
20
22
|
end
|
21
23
|
|
22
|
-
require 'cucumber/rails/rspec'
|
23
|
-
require 'webrat/core/matchers'
|
24
24
|
|
25
|
-
#
|
26
|
-
|
27
|
-
|
25
|
+
# If you set this to false, any error raised from within your app will bubble
|
26
|
+
# up to your step definition and out to cucumber unless you catch it somewhere
|
27
|
+
# on the way. You can make Rails rescue errors and render error pages on a
|
28
|
+
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
29
|
+
#
|
30
|
+
# If you set this to true, Rails will rescue all errors and render error
|
31
|
+
# pages, more or less in the same way your application would behave in the
|
32
|
+
# default production environment. It's not recommended to do this for all
|
33
|
+
# of your scenarios, as this makes it hard to discover errors in your application.
|
34
|
+
ActionController::Base.allow_rescue = false
|
35
|
+
|
36
|
+
# If you set this to true, each scenario will run in a database transaction.
|
37
|
+
# You can still turn off transactions on a per-scenario basis, simply tagging
|
38
|
+
# a feature or scenario with the @no-txn tag. If you are using Capybara,
|
39
|
+
# tagging with @culerity or @javascript will also turn transactions off.
|
40
|
+
#
|
41
|
+
# If you set this to false, transactions will be off for all scenarios,
|
42
|
+
# regardless of whether you use @no-txn or not.
|
43
|
+
#
|
44
|
+
# Beware that turning transactions off will leave data in your database
|
45
|
+
# after each scenario, which can lead to hard-to-debug failures in
|
46
|
+
# subsequent scenarios. If you do this, we recommend you create a Before
|
47
|
+
# block that will explicitly put your database in a known state.
|
48
|
+
Cucumber::Rails::World.use_transactional_fixtures = true
|
28
49
|
|
29
|
-
|
30
|
-
|
50
|
+
# How to clean your database when transactions are turned off. See
|
51
|
+
# http://github.com/bmabey/database_cleaner for more info.
|
52
|
+
if defined?(ActiveRecord::Base)
|
53
|
+
begin
|
54
|
+
require 'database_cleaner'
|
55
|
+
DatabaseCleaner.strategy = :truncation
|
56
|
+
rescue LoadError => ignore_if_database_cleaner_not_present
|
57
|
+
end
|
58
|
+
end
|
@@ -3,14 +3,20 @@ module NavigationHelpers
|
|
3
3
|
#
|
4
4
|
# When /^I go to (.+)$/ do |page_name|
|
5
5
|
#
|
6
|
-
# step definition in
|
6
|
+
# step definition in web_steps.rb
|
7
7
|
#
|
8
8
|
def path_to(page_name)
|
9
9
|
case page_name
|
10
10
|
|
11
|
-
when /the
|
11
|
+
when /the home\s?page/
|
12
12
|
'/'
|
13
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
|
+
|
14
20
|
when /request a newsletter/
|
15
21
|
request_newsletter_url('Name' => 'Joe Someone', 'Email' => 'example@example.com')
|
16
22
|
|
@@ -0,0 +1,47 @@
|
|
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
|
+
desc 'Run all features'
|
30
|
+
task :all => [:ok, :wip]
|
31
|
+
end
|
32
|
+
desc 'Alias for cucumber:ok'
|
33
|
+
task :cucumber => 'cucumber:ok'
|
34
|
+
|
35
|
+
task :default => :cucumber
|
36
|
+
|
37
|
+
task :features => :cucumber do
|
38
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
39
|
+
end
|
40
|
+
rescue LoadError
|
41
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
42
|
+
task :cucumber do
|
43
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
features/errors.feature:13:17:21:26:30
|
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
|
3
|
+
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
4
|
+
if vendored_cucumber_bin
|
5
|
+
load File.expand_path(vendored_cucumber_bin)
|
6
|
+
else
|
7
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
7
8
|
require 'cucumber'
|
8
9
|
load Cucumber::BINARY
|
9
10
|
end
|
data/examples/sinatra/app.rb
CHANGED
@@ -0,0 +1,273 @@
|
|
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 File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
10
|
+
|
11
|
+
# Commonly used webrat steps
|
12
|
+
# http://github.com/brynary/webrat
|
13
|
+
|
14
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
15
|
+
visit path_to(page_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
19
|
+
visit path_to(page_name)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^(?:|I )press "([^\"]*)"$/ do |button|
|
23
|
+
click_button(button)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^(?:|I )follow "([^\"]*)"$/ do |link|
|
27
|
+
click_link(link)
|
28
|
+
end
|
29
|
+
|
30
|
+
When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
|
31
|
+
click_link_within(parent, link)
|
32
|
+
end
|
33
|
+
|
34
|
+
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
35
|
+
fill_in(field, :with => value)
|
36
|
+
end
|
37
|
+
|
38
|
+
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
|
39
|
+
fill_in(field, :with => value)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Use this to fill in an entire form with data from a table. Example:
|
43
|
+
#
|
44
|
+
# When I fill in the following:
|
45
|
+
# | Account Number | 5002 |
|
46
|
+
# | Expiry date | 2009-11-01 |
|
47
|
+
# | Note | Nice guy |
|
48
|
+
# | Wants Email? | |
|
49
|
+
#
|
50
|
+
# TODO: Add support for checkbox, select og option
|
51
|
+
# based on naming conventions.
|
52
|
+
#
|
53
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
54
|
+
fields.rows_hash.each do |name, value|
|
55
|
+
When %{I fill in "#{name}" with "#{value}"}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
60
|
+
select(value, :from => field)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
64
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
65
|
+
When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
|
66
|
+
select_datetime(time)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
70
|
+
# you want to specify which datetime to select. Given the following view:
|
71
|
+
# <%= f.label :preferred %><br />
|
72
|
+
# <%= f.datetime_select :preferred %>
|
73
|
+
# <%= f.label :alternative %><br />
|
74
|
+
# <%= f.datetime_select :alternative %>
|
75
|
+
# The following steps would fill out the form:
|
76
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
77
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
78
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
79
|
+
select_datetime(datetime, :from => datetime_label)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
83
|
+
# When I select "2:20PM" as the time
|
84
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
85
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
86
|
+
When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
|
87
|
+
select_time(time)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
91
|
+
# specify the name of the time on the form. For example:
|
92
|
+
# When I select "7:30AM" as the "Gym" time
|
93
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
94
|
+
select_time(time, :from => time_label)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
98
|
+
# When I select "February 20, 1981" as the date
|
99
|
+
When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
|
100
|
+
select_date(date)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Use this step when using multiple date_select helpers on one page or
|
104
|
+
# you want to specify the name of the date on the form. For example:
|
105
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
106
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
107
|
+
select_date(date, :from => date_label)
|
108
|
+
end
|
109
|
+
|
110
|
+
When /^(?:|I )check "([^\"]*)"$/ do |field|
|
111
|
+
check(field)
|
112
|
+
end
|
113
|
+
|
114
|
+
When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
|
115
|
+
uncheck(field)
|
116
|
+
end
|
117
|
+
|
118
|
+
When /^(?:|I )choose "([^\"]*)"$/ do |field|
|
119
|
+
choose(field)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Adds support for validates_attachment_content_type. Without the mime-type getting
|
123
|
+
# passed to attach_file() you will get a "Photo file is not one of the allowed file types."
|
124
|
+
# error message
|
125
|
+
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
126
|
+
type = path.split(".")[1]
|
127
|
+
|
128
|
+
case type
|
129
|
+
when "jpg"
|
130
|
+
type = "image/jpg"
|
131
|
+
when "jpeg"
|
132
|
+
type = "image/jpeg"
|
133
|
+
when "png"
|
134
|
+
type = "image/png"
|
135
|
+
when "gif"
|
136
|
+
type = "image/gif"
|
137
|
+
end
|
138
|
+
|
139
|
+
attach_file(field, path, type)
|
140
|
+
end
|
141
|
+
|
142
|
+
Then /^(?:|I )should see "([^\"]*)"$/ do |text|
|
143
|
+
if defined?(Spec::Rails::Matchers)
|
144
|
+
response.should contain(text)
|
145
|
+
else
|
146
|
+
assert_contain text
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
151
|
+
within(selector) do |content|
|
152
|
+
if defined?(Spec::Rails::Matchers)
|
153
|
+
content.should contain(text)
|
154
|
+
else
|
155
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
156
|
+
assert hc.matches?(content), hc.failure_message
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
162
|
+
regexp = Regexp.new(regexp)
|
163
|
+
if defined?(Spec::Rails::Matchers)
|
164
|
+
response.should contain(regexp)
|
165
|
+
else
|
166
|
+
assert_match(regexp, response_body)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
171
|
+
within(selector) do |content|
|
172
|
+
regexp = Regexp.new(regexp)
|
173
|
+
if defined?(Spec::Rails::Matchers)
|
174
|
+
content.should contain(regexp)
|
175
|
+
else
|
176
|
+
assert_match(regexp, content)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
|
182
|
+
if defined?(Spec::Rails::Matchers)
|
183
|
+
response.should_not contain(text)
|
184
|
+
else
|
185
|
+
assert_not_contain(text)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
190
|
+
within(selector) do |content|
|
191
|
+
if defined?(Spec::Rails::Matchers)
|
192
|
+
content.should_not contain(text)
|
193
|
+
else
|
194
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
195
|
+
assert !hc.matches?(content), hc.negative_failure_message
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
201
|
+
regexp = Regexp.new(regexp)
|
202
|
+
if defined?(Spec::Rails::Matchers)
|
203
|
+
response.should_not contain(regexp)
|
204
|
+
else
|
205
|
+
assert_not_contain(regexp)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
210
|
+
within(selector) do |content|
|
211
|
+
regexp = Regexp.new(regexp)
|
212
|
+
if defined?(Spec::Rails::Matchers)
|
213
|
+
content.should_not contain(regexp)
|
214
|
+
else
|
215
|
+
assert_no_match(regexp, content)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
221
|
+
if defined?(Spec::Rails::Matchers)
|
222
|
+
field_labeled(field).value.should =~ /#{value}/
|
223
|
+
else
|
224
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
229
|
+
if defined?(Spec::Rails::Matchers)
|
230
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
231
|
+
else
|
232
|
+
assert_no_match(/#{value}/, field_labeled(field).value)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
237
|
+
if defined?(Spec::Rails::Matchers)
|
238
|
+
field_labeled(label).should be_checked
|
239
|
+
else
|
240
|
+
assert field_labeled(label).checked?
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
245
|
+
if defined?(Spec::Rails::Matchers)
|
246
|
+
field_labeled(label).should_not be_checked
|
247
|
+
else
|
248
|
+
assert !field_labeled(label).checked?
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
253
|
+
if defined?(Spec::Rails::Matchers)
|
254
|
+
URI.parse(current_url).path.should == path_to(page_name)
|
255
|
+
else
|
256
|
+
assert_equal path_to(page_name), URI.parse(current_url).path
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
261
|
+
actual_params = CGI.parse(URI.parse(current_url).query)
|
262
|
+
expected_params = Hash[expected_pairs.rows_hash.map{|k,v| [k,[v]]}]
|
263
|
+
|
264
|
+
if defined?(Spec::Rails::Matchers)
|
265
|
+
actual_params.should == expected_params
|
266
|
+
else
|
267
|
+
assert_equal expected_params, actual_params
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
Then /^show me the page$/ do
|
272
|
+
save_and_open_page
|
273
|
+
end
|