email_spec 0.6.4 → 0.6.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.
- data/History.txt +3 -0
- metadata +4 -14
- data/examples/rails3_root/features/step_definitions/email_steps.rb +0 -194
- data/examples/rails3_root/rerun.txt +0 -1
- data/examples/rails_root/rerun.txt +0 -1
- data/examples/sinatra/features/step_definitions/email_steps.rb +0 -182
- data/examples/sinatra_root/features/step_definitions/email_steps.rb +0 -194
data/History.txt
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 5
|
10
|
+
version: 0.6.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Mabey
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date:
|
20
|
+
date: 2011-01-11 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies: []
|
23
23
|
|
@@ -51,8 +51,6 @@ files:
|
|
51
51
|
- spec/email_spec/matchers_spec.rb
|
52
52
|
- spec/spec.opts
|
53
53
|
- spec/spec_helper.rb
|
54
|
-
- examples/rails3_root/features/step_definitions/email_steps.rb
|
55
|
-
- examples/rails3_root/rerun.txt
|
56
54
|
- examples/rails_root/app/controllers/application_controller.rb
|
57
55
|
- examples/rails_root/app/controllers/welcome_controller.rb
|
58
56
|
- examples/rails_root/app/helpers/application_helper.rb
|
@@ -108,7 +106,6 @@ files:
|
|
108
106
|
- examples/rails_root/public/javascripts/prototype.js
|
109
107
|
- examples/rails_root/public/robots.txt
|
110
108
|
- examples/rails_root/Rakefile
|
111
|
-
- examples/rails_root/rerun.txt
|
112
109
|
- examples/rails_root/script/about
|
113
110
|
- examples/rails_root/script/autospec
|
114
111
|
- examples/rails_root/script/console
|
@@ -138,12 +135,10 @@ files:
|
|
138
135
|
- examples/sinatra/app.rb
|
139
136
|
- examples/sinatra/features/errors.feature
|
140
137
|
- examples/sinatra/features/example.feature
|
141
|
-
- examples/sinatra/features/step_definitions/email_steps.rb
|
142
138
|
- examples/sinatra/features/step_definitions/user_steps.rb
|
143
139
|
- examples/sinatra/features/step_definitions/web_steps.rb
|
144
140
|
- examples/sinatra/features/support/env.rb
|
145
141
|
- examples/sinatra/features/support/paths.rb
|
146
|
-
- examples/sinatra_root/features/step_definitions/email_steps.rb
|
147
142
|
has_rdoc: true
|
148
143
|
homepage: http://github.com/bmabey/email-spec/
|
149
144
|
licenses: []
|
@@ -183,8 +178,6 @@ test_files:
|
|
183
178
|
- spec/email_spec/matchers_spec.rb
|
184
179
|
- spec/spec.opts
|
185
180
|
- spec/spec_helper.rb
|
186
|
-
- examples/rails3_root/features/step_definitions/email_steps.rb
|
187
|
-
- examples/rails3_root/rerun.txt
|
188
181
|
- examples/rails_root/app/controllers/application_controller.rb
|
189
182
|
- examples/rails_root/app/controllers/welcome_controller.rb
|
190
183
|
- examples/rails_root/app/helpers/application_helper.rb
|
@@ -240,7 +233,6 @@ test_files:
|
|
240
233
|
- examples/rails_root/public/javascripts/prototype.js
|
241
234
|
- examples/rails_root/public/robots.txt
|
242
235
|
- examples/rails_root/Rakefile
|
243
|
-
- examples/rails_root/rerun.txt
|
244
236
|
- examples/rails_root/script/about
|
245
237
|
- examples/rails_root/script/autospec
|
246
238
|
- examples/rails_root/script/console
|
@@ -270,9 +262,7 @@ test_files:
|
|
270
262
|
- examples/sinatra/app.rb
|
271
263
|
- examples/sinatra/features/errors.feature
|
272
264
|
- examples/sinatra/features/example.feature
|
273
|
-
- examples/sinatra/features/step_definitions/email_steps.rb
|
274
265
|
- examples/sinatra/features/step_definitions/user_steps.rb
|
275
266
|
- examples/sinatra/features/step_definitions/web_steps.rb
|
276
267
|
- examples/sinatra/features/support/env.rb
|
277
268
|
- examples/sinatra/features/support/paths.rb
|
278
|
-
- examples/sinatra_root/features/step_definitions/email_steps.rb
|
@@ -1,194 +0,0 @@
|
|
1
|
-
# Commonly used email steps
|
2
|
-
#
|
3
|
-
# To add your own steps make a custom_email_steps.rb
|
4
|
-
# The provided methods are:
|
5
|
-
#
|
6
|
-
# last_email_address
|
7
|
-
# reset_mailer
|
8
|
-
# open_last_email
|
9
|
-
# visit_in_email
|
10
|
-
# unread_emails_for
|
11
|
-
# mailbox_for
|
12
|
-
# current_email
|
13
|
-
# open_email
|
14
|
-
# read_emails_for
|
15
|
-
# find_email
|
16
|
-
#
|
17
|
-
# General form for email scenarios are:
|
18
|
-
# - clear the email queue (done automatically by email_spec)
|
19
|
-
# - execute steps that sends an email
|
20
|
-
# - check the user received an/no/[0-9] emails
|
21
|
-
# - open the email
|
22
|
-
# - inspect the email contents
|
23
|
-
# - interact with the email (e.g. click links)
|
24
|
-
#
|
25
|
-
# The Cucumber steps below are setup in this order.
|
26
|
-
|
27
|
-
module EmailHelpers
|
28
|
-
def current_email_address
|
29
|
-
# Replace with your a way to find your current email. e.g @current_user.email
|
30
|
-
# last_email_address will return the last email address used by email spec to find an email.
|
31
|
-
# Note that last_email_address will be reset after each Scenario.
|
32
|
-
last_email_address || "example@example.com"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
World(EmailHelpers)
|
37
|
-
|
38
|
-
#
|
39
|
-
# Reset the e-mail queue within a scenario.
|
40
|
-
# This is done automatically before each scenario.
|
41
|
-
#
|
42
|
-
|
43
|
-
Given /^(?:a clear email queue|no emails have been sent)$/ do
|
44
|
-
reset_mailer
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Check how many emails have been sent/received
|
49
|
-
#
|
50
|
-
|
51
|
-
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
52
|
-
unread_emails_for(address).size.should == parse_email_count(amount)
|
53
|
-
end
|
54
|
-
|
55
|
-
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
56
|
-
mailbox_for(address).size.should == parse_email_count(amount)
|
57
|
-
end
|
58
|
-
|
59
|
-
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
60
|
-
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
|
61
|
-
end
|
62
|
-
|
63
|
-
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
64
|
-
open_email(address, :with_text => expected_body)
|
65
|
-
end
|
66
|
-
|
67
|
-
#
|
68
|
-
# Accessing emails
|
69
|
-
#
|
70
|
-
|
71
|
-
# Opens the most recently received email
|
72
|
-
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
73
|
-
open_email(address)
|
74
|
-
end
|
75
|
-
|
76
|
-
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
77
|
-
open_email(address, :with_subject => subject)
|
78
|
-
end
|
79
|
-
|
80
|
-
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
81
|
-
open_email(address, :with_text => text)
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Inspect the Email Contents
|
86
|
-
#
|
87
|
-
|
88
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
89
|
-
current_email.should have_subject(text)
|
90
|
-
end
|
91
|
-
|
92
|
-
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
93
|
-
current_email.should have_subject(Regexp.new(text))
|
94
|
-
end
|
95
|
-
|
96
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
97
|
-
current_email.default_part_body.to_s.should include(text)
|
98
|
-
end
|
99
|
-
|
100
|
-
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
101
|
-
current_email.default_part_body.to_s.should =~ Regexp.new(text)
|
102
|
-
end
|
103
|
-
|
104
|
-
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
105
|
-
current_email.should be_delivered_from(text)
|
106
|
-
end
|
107
|
-
|
108
|
-
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
109
|
-
current_email.should have_header(name, text)
|
110
|
-
end
|
111
|
-
|
112
|
-
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
113
|
-
current_email.should have_header(name, Regexp.new(text))
|
114
|
-
end
|
115
|
-
|
116
|
-
Then /^I should see it is a multi\-part email$/ do
|
117
|
-
current_email.should be_multipart
|
118
|
-
end
|
119
|
-
|
120
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
|
121
|
-
current_email.html_part.body.to_s.should include(text)
|
122
|
-
end
|
123
|
-
|
124
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
|
125
|
-
current_email.text_part.body.to_s.should include(text)
|
126
|
-
end
|
127
|
-
|
128
|
-
#
|
129
|
-
# Inspect the Email Attachments
|
130
|
-
#
|
131
|
-
|
132
|
-
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
133
|
-
current_email_attachments.size.should == parse_email_count(amount)
|
134
|
-
end
|
135
|
-
|
136
|
-
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
137
|
-
current_email_attachments.select { |a| a.filename == filename }.size.should == parse_email_count(amount)
|
138
|
-
end
|
139
|
-
|
140
|
-
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
141
|
-
current_email_attachments[(index.to_i - 1)].filename.should == filename
|
142
|
-
end
|
143
|
-
|
144
|
-
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
145
|
-
current_email_attachments.select { |a| a.content_type.include?(content_type) }.size.should == parse_email_count(amount)
|
146
|
-
end
|
147
|
-
|
148
|
-
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
149
|
-
current_email_attachments[(index.to_i - 1)].content_type.should include(content_type)
|
150
|
-
end
|
151
|
-
|
152
|
-
Then /^all attachments should not be blank$/ do
|
153
|
-
current_email_attachments.each do |attachment|
|
154
|
-
attachment.read.size.should_not == 0
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
Then /^show me a list of email attachments$/ do
|
159
|
-
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
160
|
-
end
|
161
|
-
|
162
|
-
#
|
163
|
-
# Interact with Email Contents
|
164
|
-
#
|
165
|
-
|
166
|
-
When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
|
167
|
-
visit_in_email(link)
|
168
|
-
end
|
169
|
-
|
170
|
-
When /^(?:I|they) click the first link in the email$/ do
|
171
|
-
click_first_link_in_email
|
172
|
-
end
|
173
|
-
|
174
|
-
#
|
175
|
-
# Debugging
|
176
|
-
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
177
|
-
# Patches accepted. ;)
|
178
|
-
#
|
179
|
-
|
180
|
-
Then /^save and open current email$/ do
|
181
|
-
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
182
|
-
end
|
183
|
-
|
184
|
-
Then /^save and open all text emails$/ do
|
185
|
-
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
186
|
-
end
|
187
|
-
|
188
|
-
Then /^save and open all html emails$/ do
|
189
|
-
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
190
|
-
end
|
191
|
-
|
192
|
-
Then /^save and open all raw emails$/ do
|
193
|
-
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
194
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
features/errors.feature:13:17:21:26:30
|
@@ -1 +0,0 @@
|
|
1
|
-
features/errors.feature:13:17:21:26:30
|
@@ -1,182 +0,0 @@
|
|
1
|
-
# Commonly used email steps
|
2
|
-
#
|
3
|
-
# To add your own steps make a custom_email_steps.rb
|
4
|
-
# The provided methods are:
|
5
|
-
#
|
6
|
-
# last_email_address
|
7
|
-
# reset_mailer
|
8
|
-
# open_last_email
|
9
|
-
# visit_in_email
|
10
|
-
# unread_emails_for
|
11
|
-
# mailbox_for
|
12
|
-
# current_email
|
13
|
-
# open_email
|
14
|
-
# read_emails_for
|
15
|
-
# find_email
|
16
|
-
#
|
17
|
-
# General form for email scenarios are:
|
18
|
-
# - clear the email queue (done automatically by email_spec)
|
19
|
-
# - execute steps that sends an email
|
20
|
-
# - check the user received an/no/[0-9] emails
|
21
|
-
# - open the email
|
22
|
-
# - inspect the email contents
|
23
|
-
# - interact with the email (e.g. click links)
|
24
|
-
#
|
25
|
-
# The Cucumber steps below are setup in this order.
|
26
|
-
|
27
|
-
module EmailHelpers
|
28
|
-
def current_email_address
|
29
|
-
# Replace with your a way to find your current email. e.g @current_user.email
|
30
|
-
# last_email_address will return the last email address used by email spec to find an email.
|
31
|
-
# Note that last_email_address will be reset after each Scenario.
|
32
|
-
last_email_address || "example@example.com"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
World(EmailHelpers)
|
37
|
-
|
38
|
-
#
|
39
|
-
# Reset the e-mail queue within a scenario.
|
40
|
-
# This is done automatically before each scenario.
|
41
|
-
#
|
42
|
-
|
43
|
-
Given /^(?:a clear email queue|no emails have been sent)$/ do
|
44
|
-
reset_mailer
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Check how many emails have been sent/received
|
49
|
-
#
|
50
|
-
|
51
|
-
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
52
|
-
unread_emails_for(address).size.should == parse_email_count(amount)
|
53
|
-
end
|
54
|
-
|
55
|
-
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
56
|
-
mailbox_for(address).size.should == parse_email_count(amount)
|
57
|
-
end
|
58
|
-
|
59
|
-
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
60
|
-
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
|
61
|
-
end
|
62
|
-
|
63
|
-
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
64
|
-
open_email(address, :with_text => expected_body)
|
65
|
-
end
|
66
|
-
|
67
|
-
#
|
68
|
-
# Accessing emails
|
69
|
-
#
|
70
|
-
|
71
|
-
# Opens the most recently received email
|
72
|
-
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
73
|
-
open_email(address)
|
74
|
-
end
|
75
|
-
|
76
|
-
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
77
|
-
open_email(address, :with_subject => subject)
|
78
|
-
end
|
79
|
-
|
80
|
-
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
81
|
-
open_email(address, :with_text => text)
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Inspect the Email Contents
|
86
|
-
#
|
87
|
-
|
88
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
89
|
-
current_email.should have_subject(text)
|
90
|
-
end
|
91
|
-
|
92
|
-
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
93
|
-
current_email.should have_subject(Regexp.new(text))
|
94
|
-
end
|
95
|
-
|
96
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
97
|
-
current_email.body.should include(text)
|
98
|
-
end
|
99
|
-
|
100
|
-
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
101
|
-
current_email.body.should =~ Regexp.new(text)
|
102
|
-
end
|
103
|
-
|
104
|
-
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
105
|
-
current_email.should be_delivered_from(text)
|
106
|
-
end
|
107
|
-
|
108
|
-
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
109
|
-
current_email.should have_header(name, text)
|
110
|
-
end
|
111
|
-
|
112
|
-
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
113
|
-
current_email.should have_header(name, Regexp.new(text))
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# Inspect the Email Attachments
|
118
|
-
#
|
119
|
-
|
120
|
-
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
121
|
-
current_email_attachments.size.should == parse_email_count(amount)
|
122
|
-
end
|
123
|
-
|
124
|
-
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
125
|
-
current_email_attachments.select { |a| a.original_filename == filename }.size.should == parse_email_count(amount)
|
126
|
-
end
|
127
|
-
|
128
|
-
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
129
|
-
current_email_attachments[(index.to_i - 1)].original_filename.should == filename
|
130
|
-
end
|
131
|
-
|
132
|
-
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
133
|
-
current_email_attachments.select { |a| a.content_type == content_type }.size.should == parse_email_count(amount)
|
134
|
-
end
|
135
|
-
|
136
|
-
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
137
|
-
current_email_attachments[(index.to_i - 1)].content_type.should == content_type
|
138
|
-
end
|
139
|
-
|
140
|
-
Then /^all attachments should not be blank$/ do
|
141
|
-
current_email_attachments.each do |attachment|
|
142
|
-
attachment.size.should_not == 0
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
Then /^show me a list of email attachments$/ do
|
147
|
-
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
148
|
-
end
|
149
|
-
|
150
|
-
#
|
151
|
-
# Interact with Email Contents
|
152
|
-
#
|
153
|
-
|
154
|
-
When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
|
155
|
-
visit_in_email(link)
|
156
|
-
end
|
157
|
-
|
158
|
-
When /^(?:I|they) click the first link in the email$/ do
|
159
|
-
click_first_link_in_email
|
160
|
-
end
|
161
|
-
|
162
|
-
#
|
163
|
-
# Debugging
|
164
|
-
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
165
|
-
# Patches accepted. ;)
|
166
|
-
#
|
167
|
-
|
168
|
-
Then /^save and open current email$/ do
|
169
|
-
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
170
|
-
end
|
171
|
-
|
172
|
-
Then /^save and open all text emails$/ do
|
173
|
-
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
174
|
-
end
|
175
|
-
|
176
|
-
Then /^save and open all html emails$/ do
|
177
|
-
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
178
|
-
end
|
179
|
-
|
180
|
-
Then /^save and open all raw emails$/ do
|
181
|
-
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
182
|
-
end
|
@@ -1,194 +0,0 @@
|
|
1
|
-
# Commonly used email steps
|
2
|
-
#
|
3
|
-
# To add your own steps make a custom_email_steps.rb
|
4
|
-
# The provided methods are:
|
5
|
-
#
|
6
|
-
# last_email_address
|
7
|
-
# reset_mailer
|
8
|
-
# open_last_email
|
9
|
-
# visit_in_email
|
10
|
-
# unread_emails_for
|
11
|
-
# mailbox_for
|
12
|
-
# current_email
|
13
|
-
# open_email
|
14
|
-
# read_emails_for
|
15
|
-
# find_email
|
16
|
-
#
|
17
|
-
# General form for email scenarios are:
|
18
|
-
# - clear the email queue (done automatically by email_spec)
|
19
|
-
# - execute steps that sends an email
|
20
|
-
# - check the user received an/no/[0-9] emails
|
21
|
-
# - open the email
|
22
|
-
# - inspect the email contents
|
23
|
-
# - interact with the email (e.g. click links)
|
24
|
-
#
|
25
|
-
# The Cucumber steps below are setup in this order.
|
26
|
-
|
27
|
-
module EmailHelpers
|
28
|
-
def current_email_address
|
29
|
-
# Replace with your a way to find your current email. e.g @current_user.email
|
30
|
-
# last_email_address will return the last email address used by email spec to find an email.
|
31
|
-
# Note that last_email_address will be reset after each Scenario.
|
32
|
-
last_email_address || "example@example.com"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
World(EmailHelpers)
|
37
|
-
|
38
|
-
#
|
39
|
-
# Reset the e-mail queue within a scenario.
|
40
|
-
# This is done automatically before each scenario.
|
41
|
-
#
|
42
|
-
|
43
|
-
Given /^(?:a clear email queue|no emails have been sent)$/ do
|
44
|
-
reset_mailer
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Check how many emails have been sent/received
|
49
|
-
#
|
50
|
-
|
51
|
-
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
52
|
-
unread_emails_for(address).size.should == parse_email_count(amount)
|
53
|
-
end
|
54
|
-
|
55
|
-
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
56
|
-
mailbox_for(address).size.should == parse_email_count(amount)
|
57
|
-
end
|
58
|
-
|
59
|
-
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
60
|
-
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
|
61
|
-
end
|
62
|
-
|
63
|
-
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
64
|
-
open_email(address, :with_text => expected_body)
|
65
|
-
end
|
66
|
-
|
67
|
-
#
|
68
|
-
# Accessing emails
|
69
|
-
#
|
70
|
-
|
71
|
-
# Opens the most recently received email
|
72
|
-
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
73
|
-
open_email(address)
|
74
|
-
end
|
75
|
-
|
76
|
-
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
77
|
-
open_email(address, :with_subject => subject)
|
78
|
-
end
|
79
|
-
|
80
|
-
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
81
|
-
open_email(address, :with_text => text)
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Inspect the Email Contents
|
86
|
-
#
|
87
|
-
|
88
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
89
|
-
current_email.should have_subject(text)
|
90
|
-
end
|
91
|
-
|
92
|
-
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
93
|
-
current_email.should have_subject(Regexp.new(text))
|
94
|
-
end
|
95
|
-
|
96
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
97
|
-
current_email.default_part_body.to_s.should include(text)
|
98
|
-
end
|
99
|
-
|
100
|
-
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
101
|
-
current_email.default_part_body.to_s.should =~ Regexp.new(text)
|
102
|
-
end
|
103
|
-
|
104
|
-
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
105
|
-
current_email.should be_delivered_from(text)
|
106
|
-
end
|
107
|
-
|
108
|
-
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
109
|
-
current_email.should have_header(name, text)
|
110
|
-
end
|
111
|
-
|
112
|
-
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
113
|
-
current_email.should have_header(name, Regexp.new(text))
|
114
|
-
end
|
115
|
-
|
116
|
-
Then /^I should see it is a multi\-part email$/ do
|
117
|
-
current_email.should be_multipart
|
118
|
-
end
|
119
|
-
|
120
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
|
121
|
-
current_email.html_part.body.to_s.should include(text)
|
122
|
-
end
|
123
|
-
|
124
|
-
Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
|
125
|
-
current_email.text_part.body.to_s.should include(text)
|
126
|
-
end
|
127
|
-
|
128
|
-
#
|
129
|
-
# Inspect the Email Attachments
|
130
|
-
#
|
131
|
-
|
132
|
-
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
133
|
-
current_email_attachments.size.should == parse_email_count(amount)
|
134
|
-
end
|
135
|
-
|
136
|
-
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
137
|
-
current_email_attachments.select { |a| a.filename == filename }.size.should == parse_email_count(amount)
|
138
|
-
end
|
139
|
-
|
140
|
-
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
141
|
-
current_email_attachments[(index.to_i - 1)].filename.should == filename
|
142
|
-
end
|
143
|
-
|
144
|
-
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
145
|
-
current_email_attachments.select { |a| a.content_type.include?(content_type) }.size.should == parse_email_count(amount)
|
146
|
-
end
|
147
|
-
|
148
|
-
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
149
|
-
current_email_attachments[(index.to_i - 1)].content_type.should include(content_type)
|
150
|
-
end
|
151
|
-
|
152
|
-
Then /^all attachments should not be blank$/ do
|
153
|
-
current_email_attachments.each do |attachment|
|
154
|
-
attachment.read.size.should_not == 0
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
Then /^show me a list of email attachments$/ do
|
159
|
-
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
160
|
-
end
|
161
|
-
|
162
|
-
#
|
163
|
-
# Interact with Email Contents
|
164
|
-
#
|
165
|
-
|
166
|
-
When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
|
167
|
-
visit_in_email(link)
|
168
|
-
end
|
169
|
-
|
170
|
-
When /^(?:I|they) click the first link in the email$/ do
|
171
|
-
click_first_link_in_email
|
172
|
-
end
|
173
|
-
|
174
|
-
#
|
175
|
-
# Debugging
|
176
|
-
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
177
|
-
# Patches accepted. ;)
|
178
|
-
#
|
179
|
-
|
180
|
-
Then /^save and open current email$/ do
|
181
|
-
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
182
|
-
end
|
183
|
-
|
184
|
-
Then /^save and open all text emails$/ do
|
185
|
-
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
186
|
-
end
|
187
|
-
|
188
|
-
Then /^save and open all html emails$/ do
|
189
|
-
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
190
|
-
end
|
191
|
-
|
192
|
-
Then /^save and open all raw emails$/ do
|
193
|
-
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
194
|
-
end
|