email_spec 2.2.1 → 2.2.2
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 +4 -4
- data/Changelog.md +8 -1
- data/examples/rails4_root/features/step_definitions/email_steps.rb +226 -0
- data/examples/sinatra_root/features/step_definitions/email_steps.rb +226 -0
- data/lib/email_spec/deliveries.rb +12 -44
- data/lib/email_spec/version.rb +3 -1
- data/spec/email_spec/mail_ext_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67b5cef2ce1c7cb7d919d61567a3fcdedab6747bf016962ca03da9b1d2abf660
|
4
|
+
data.tar.gz: 3694cba82a8b25469d5c0a7e5ec9f7d688471d357926a46cb37e7290320222f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 780394b891b7fbcc9a75629fd20608e99730cca2a1ecf5882193d7e8f2fc59fd115c4360d517c1a0f94d7b6e8ca56c0bf01e00ae91f8f42f592d0d169fed09ae
|
7
|
+
data.tar.gz: 790bb0a29b5c44aacb5ddfb5c9d9f049cedea133df51a2ccf66c41f364b4610450ebb01ce4aa92a2f18ef815e4c48d402863fcb5a41530e7d819f3475242f01c
|
data/Changelog.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
## 2.2.2 2023-06-26
|
2
|
+
|
3
|
+
* [Defer accommodating different delivery methods to runtime](https://github.com/email-spec/email-spec/pull/224)
|
4
|
+
|
1
5
|
## 2.2.1 2022-09-12
|
2
6
|
|
3
|
-
* [
|
7
|
+
* [Support to decode part in EmailSpec::MailExt#default_part_body](https://github.com/email-spec/email-spec/pull/211)
|
8
|
+
* [Drop rubyforge_project from gemspec](https://github.com/email-spec/email-spec/pull/215)
|
9
|
+
* [Avoid eagerly loading ActionMailer::Base](https://github.com/email-spec/email-spec/pull/219)
|
10
|
+
* [README: use SVG badges](https://github.com/email-spec/email-spec/pull/217)
|
4
11
|
|
5
12
|
## 2.2.0 2018-04-03
|
6
13
|
|
@@ -0,0 +1,226 @@
|
|
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
|
+
expect(unread_emails_for(address).size).to eql parse_email_count(amount)
|
53
|
+
end
|
54
|
+
|
55
|
+
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
56
|
+
expect(mailbox_for(address).size).to eql parse_email_count(amount)
|
57
|
+
end
|
58
|
+
|
59
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
60
|
+
expect(unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size).to eql parse_email_count(amount)
|
61
|
+
end
|
62
|
+
|
63
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject \/([^"]*?)\/$/ do |address, amount, subject|
|
64
|
+
expect(unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size).to eql parse_email_count(amount)
|
65
|
+
end
|
66
|
+
|
67
|
+
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
68
|
+
open_email(address, :with_text => expected_body)
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Accessing emails
|
73
|
+
#
|
74
|
+
|
75
|
+
# Opens the most recently received email
|
76
|
+
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
77
|
+
open_email(address)
|
78
|
+
end
|
79
|
+
|
80
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
81
|
+
open_email(address, :with_subject => subject)
|
82
|
+
end
|
83
|
+
|
84
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject \/([^"]*?)\/$/ do |address, subject|
|
85
|
+
open_email(address, :with_subject => Regexp.new(subject))
|
86
|
+
end
|
87
|
+
|
88
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
89
|
+
open_email(address, :with_text => text)
|
90
|
+
end
|
91
|
+
|
92
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text \/([^"]*?)\/$/ do |address, text|
|
93
|
+
open_email(address, :with_text => Regexp.new(text))
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Inspect the Email Contents
|
98
|
+
#
|
99
|
+
|
100
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
101
|
+
expect(current_email).to have_subject(text)
|
102
|
+
end
|
103
|
+
|
104
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
105
|
+
expect(current_email).to have_subject(Regexp.new(text))
|
106
|
+
end
|
107
|
+
|
108
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email subject$/ do |text|
|
109
|
+
expect(current_email).not_to have_subject(text)
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email subject$/ do |text|
|
113
|
+
expect(current_email).not_to have_subject(Regexp.new(text))
|
114
|
+
end
|
115
|
+
|
116
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
117
|
+
expect(current_email.default_part_body.to_s).to include(text)
|
118
|
+
end
|
119
|
+
|
120
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email body$/ do |text|
|
121
|
+
expect(current_email.default_part_body.to_s).not_to include(text)
|
122
|
+
end
|
123
|
+
|
124
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
125
|
+
expect(current_email.default_part_body.to_s).to match Regexp.new(text)
|
126
|
+
end
|
127
|
+
|
128
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email body$/ do |text|
|
129
|
+
expect(current_email.default_part_body.to_s).not_to match Regexp.new(text)
|
130
|
+
end
|
131
|
+
|
132
|
+
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
133
|
+
expect(current_email).to be_delivered_from(text)
|
134
|
+
end
|
135
|
+
|
136
|
+
Then /^(?:I|they) should see the email reply to "([^"]*?)"$/ do |text|
|
137
|
+
expect(current_email).to have_reply_to(text)
|
138
|
+
end
|
139
|
+
|
140
|
+
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
141
|
+
expect(current_email).to have_header(name, text)
|
142
|
+
end
|
143
|
+
|
144
|
+
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
145
|
+
expect(current_email).to have_header(name, Regexp.new(text))
|
146
|
+
end
|
147
|
+
|
148
|
+
Then /^I should see it is a multi\-part email$/ do
|
149
|
+
expect(current_email).to be_multipart
|
150
|
+
end
|
151
|
+
|
152
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
|
153
|
+
expect(current_email.html_part.body.to_s).to include(text)
|
154
|
+
end
|
155
|
+
|
156
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
|
157
|
+
expect(current_email.text_part.body.to_s).to include(text)
|
158
|
+
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# Inspect the Email Attachments
|
162
|
+
#
|
163
|
+
|
164
|
+
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
165
|
+
expect(current_email_attachments.size).to eql parse_email_count(amount)
|
166
|
+
end
|
167
|
+
|
168
|
+
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
169
|
+
expect(current_email_attachments.select { |a| a.filename == filename }.size).to eql parse_email_count(amount)
|
170
|
+
end
|
171
|
+
|
172
|
+
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
173
|
+
expect(current_email_attachments[(index.to_i - 1)].filename).to eql filename
|
174
|
+
end
|
175
|
+
|
176
|
+
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
177
|
+
expect(current_email_attachments.select { |a| a.content_type.include?(content_type) }.size).to eql parse_email_count(amount)
|
178
|
+
end
|
179
|
+
|
180
|
+
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
181
|
+
expect(current_email_attachments[(index.to_i - 1)].content_type).to include(content_type)
|
182
|
+
end
|
183
|
+
|
184
|
+
Then /^all attachments should not be blank$/ do
|
185
|
+
current_email_attachments.each do |attachment|
|
186
|
+
expect(attachment.read.size).to_not eql 0
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
Then /^show me a list of email attachments$/ do
|
191
|
+
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
192
|
+
end
|
193
|
+
|
194
|
+
#
|
195
|
+
# Interact with Email Contents
|
196
|
+
#
|
197
|
+
|
198
|
+
When /^(?:I|they|"([^"]*?)") follows? "([^"]*?)" in the email$/ do |address, link|
|
199
|
+
visit_in_email(link, address)
|
200
|
+
end
|
201
|
+
|
202
|
+
When /^(?:I|they) click the first link in the email$/ do
|
203
|
+
click_first_link_in_email
|
204
|
+
end
|
205
|
+
|
206
|
+
#
|
207
|
+
# Debugging
|
208
|
+
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
209
|
+
# Patches accepted. ;)
|
210
|
+
#
|
211
|
+
|
212
|
+
Then /^save and open current email$/ do
|
213
|
+
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
214
|
+
end
|
215
|
+
|
216
|
+
Then /^save and open all text emails$/ do
|
217
|
+
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
218
|
+
end
|
219
|
+
|
220
|
+
Then /^save and open all html emails$/ do
|
221
|
+
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
222
|
+
end
|
223
|
+
|
224
|
+
Then /^save and open all raw emails$/ do
|
225
|
+
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
226
|
+
end
|
@@ -0,0 +1,226 @@
|
|
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
|
+
expect(unread_emails_for(address).size).to eql parse_email_count(amount)
|
53
|
+
end
|
54
|
+
|
55
|
+
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
56
|
+
expect(mailbox_for(address).size).to eql parse_email_count(amount)
|
57
|
+
end
|
58
|
+
|
59
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
60
|
+
expect(unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size).to eql parse_email_count(amount)
|
61
|
+
end
|
62
|
+
|
63
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject \/([^"]*?)\/$/ do |address, amount, subject|
|
64
|
+
expect(unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size).to eql parse_email_count(amount)
|
65
|
+
end
|
66
|
+
|
67
|
+
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
68
|
+
open_email(address, :with_text => expected_body)
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Accessing emails
|
73
|
+
#
|
74
|
+
|
75
|
+
# Opens the most recently received email
|
76
|
+
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
77
|
+
open_email(address)
|
78
|
+
end
|
79
|
+
|
80
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
81
|
+
open_email(address, :with_subject => subject)
|
82
|
+
end
|
83
|
+
|
84
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject \/([^"]*?)\/$/ do |address, subject|
|
85
|
+
open_email(address, :with_subject => Regexp.new(subject))
|
86
|
+
end
|
87
|
+
|
88
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
89
|
+
open_email(address, :with_text => text)
|
90
|
+
end
|
91
|
+
|
92
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text \/([^"]*?)\/$/ do |address, text|
|
93
|
+
open_email(address, :with_text => Regexp.new(text))
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Inspect the Email Contents
|
98
|
+
#
|
99
|
+
|
100
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
101
|
+
expect(current_email).to have_subject(text)
|
102
|
+
end
|
103
|
+
|
104
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
105
|
+
expect(current_email).to have_subject(Regexp.new(text))
|
106
|
+
end
|
107
|
+
|
108
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email subject$/ do |text|
|
109
|
+
expect(current_email).not_to have_subject(text)
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email subject$/ do |text|
|
113
|
+
expect(current_email).not_to have_subject(Regexp.new(text))
|
114
|
+
end
|
115
|
+
|
116
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
117
|
+
expect(current_email.default_part_body.to_s).to include(text)
|
118
|
+
end
|
119
|
+
|
120
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email body$/ do |text|
|
121
|
+
expect(current_email.default_part_body.to_s).not_to include(text)
|
122
|
+
end
|
123
|
+
|
124
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
125
|
+
expect(current_email.default_part_body.to_s).to match Regexp.new(text)
|
126
|
+
end
|
127
|
+
|
128
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email body$/ do |text|
|
129
|
+
expect(current_email.default_part_body.to_s).not_to match Regexp.new(text)
|
130
|
+
end
|
131
|
+
|
132
|
+
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
133
|
+
expect(current_email).to be_delivered_from(text)
|
134
|
+
end
|
135
|
+
|
136
|
+
Then /^(?:I|they) should see the email reply to "([^"]*?)"$/ do |text|
|
137
|
+
expect(current_email).to have_reply_to(text)
|
138
|
+
end
|
139
|
+
|
140
|
+
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
141
|
+
expect(current_email).to have_header(name, text)
|
142
|
+
end
|
143
|
+
|
144
|
+
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
145
|
+
expect(current_email).to have_header(name, Regexp.new(text))
|
146
|
+
end
|
147
|
+
|
148
|
+
Then /^I should see it is a multi\-part email$/ do
|
149
|
+
expect(current_email).to be_multipart
|
150
|
+
end
|
151
|
+
|
152
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
|
153
|
+
expect(current_email.html_part.body.to_s).to include(text)
|
154
|
+
end
|
155
|
+
|
156
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
|
157
|
+
expect(current_email.text_part.body.to_s).to include(text)
|
158
|
+
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# Inspect the Email Attachments
|
162
|
+
#
|
163
|
+
|
164
|
+
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
165
|
+
expect(current_email_attachments.size).to eql parse_email_count(amount)
|
166
|
+
end
|
167
|
+
|
168
|
+
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
169
|
+
expect(current_email_attachments.select { |a| a.filename == filename }.size).to eql parse_email_count(amount)
|
170
|
+
end
|
171
|
+
|
172
|
+
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
173
|
+
expect(current_email_attachments[(index.to_i - 1)].filename).to eql filename
|
174
|
+
end
|
175
|
+
|
176
|
+
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
177
|
+
expect(current_email_attachments.select { |a| a.content_type.include?(content_type) }.size).to eql parse_email_count(amount)
|
178
|
+
end
|
179
|
+
|
180
|
+
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
181
|
+
expect(current_email_attachments[(index.to_i - 1)].content_type).to include(content_type)
|
182
|
+
end
|
183
|
+
|
184
|
+
Then /^all attachments should not be blank$/ do
|
185
|
+
current_email_attachments.each do |attachment|
|
186
|
+
expect(attachment.read.size).to_not eql 0
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
Then /^show me a list of email attachments$/ do
|
191
|
+
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
192
|
+
end
|
193
|
+
|
194
|
+
#
|
195
|
+
# Interact with Email Contents
|
196
|
+
#
|
197
|
+
|
198
|
+
When /^(?:I|they|"([^"]*?)") follows? "([^"]*?)" in the email$/ do |address, link|
|
199
|
+
visit_in_email(link, address)
|
200
|
+
end
|
201
|
+
|
202
|
+
When /^(?:I|they) click the first link in the email$/ do
|
203
|
+
click_first_link_in_email
|
204
|
+
end
|
205
|
+
|
206
|
+
#
|
207
|
+
# Debugging
|
208
|
+
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
209
|
+
# Patches accepted. ;)
|
210
|
+
#
|
211
|
+
|
212
|
+
Then /^save and open current email$/ do
|
213
|
+
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
214
|
+
end
|
215
|
+
|
216
|
+
Then /^save and open all text emails$/ do
|
217
|
+
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
218
|
+
end
|
219
|
+
|
220
|
+
Then /^save and open all html emails$/ do
|
221
|
+
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
222
|
+
end
|
223
|
+
|
224
|
+
Then /^save and open all raw emails$/ do
|
225
|
+
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
226
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module EmailSpec
|
2
|
-
module
|
2
|
+
module Deliveries
|
3
3
|
def all_emails
|
4
4
|
deliveries
|
5
5
|
end
|
@@ -9,7 +9,9 @@ module EmailSpec
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def reset_mailer
|
12
|
-
if defined?(ActionMailer) && ActionMailer::Base.delivery_method == :
|
12
|
+
if defined?(ActionMailer) && ActionMailer::Base.delivery_method == :activerecord
|
13
|
+
Email.delete_all
|
14
|
+
elsif defined?(ActionMailer) && ActionMailer::Base.delivery_method == :cache
|
13
15
|
mailer.clear_cache
|
14
16
|
else
|
15
17
|
deliveries.clear
|
@@ -23,36 +25,22 @@ module EmailSpec
|
|
23
25
|
protected
|
24
26
|
|
25
27
|
def deliveries
|
26
|
-
if
|
28
|
+
if defined?(Pony)
|
29
|
+
Pony.deliveries
|
30
|
+
elsif ActionMailer::Base.delivery_method == :activerecord
|
31
|
+
Email.all.map { |email| parse_ar_to_mail(email) }
|
32
|
+
elsif ActionMailer::Base.delivery_method == :cache
|
27
33
|
mailer.cached_deliveries
|
28
34
|
else
|
29
35
|
mailer.deliveries
|
30
36
|
end
|
31
37
|
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module ARMailerDeliveries
|
35
|
-
def all_emails
|
36
|
-
Email.all.map{ |email| parse_to_mail(email) }
|
37
|
-
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
41
|
-
parse_to_mail(email)
|
42
|
-
else
|
43
|
-
raise("No email has been sent!")
|
44
|
-
end
|
39
|
+
def mailer
|
40
|
+
ActionMailer::Base
|
45
41
|
end
|
46
42
|
|
47
|
-
def
|
48
|
-
Email.delete_all
|
49
|
-
end
|
50
|
-
|
51
|
-
def mailbox_for(address)
|
52
|
-
Email.all.select { |email| email.destinations.include?(address) }.map{ |email| parse_to_mail(email) }
|
53
|
-
end
|
54
|
-
|
55
|
-
def parse_to_mail(email)
|
43
|
+
def parse_ar_to_mail(email)
|
56
44
|
Mail.read(email.mail)
|
57
45
|
end
|
58
46
|
end
|
@@ -68,24 +56,4 @@ module EmailSpec
|
|
68
56
|
end
|
69
57
|
end
|
70
58
|
end
|
71
|
-
|
72
|
-
module Deliveries
|
73
|
-
if defined?(Pony)
|
74
|
-
def deliveries; Pony::deliveries ; end
|
75
|
-
include EmailSpec::MailerDeliveries
|
76
|
-
else
|
77
|
-
ActiveSupport.on_load(:action_mailer) do
|
78
|
-
if delivery_method == :activerecord
|
79
|
-
::EmailSpec::Helpers.include EmailSpec::ARMailerDeliveries
|
80
|
-
else
|
81
|
-
::EmailSpec::Deliveries.module_eval do
|
82
|
-
def mailer
|
83
|
-
ActionMailer::Base
|
84
|
-
end
|
85
|
-
end
|
86
|
-
::EmailSpec::Helpers.include ::EmailSpec::MailerDeliveries
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
59
|
end
|
data/lib/email_spec/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,6 @@ require 'action_mailer'
|
|
3
3
|
require 'mail'
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/email_spec.rb')
|
5
5
|
|
6
|
-
# Trigger loading ActionMailer::Base
|
7
|
-
ActionMailer::Base
|
8
|
-
|
9
6
|
RSpec.configure do |config|
|
10
7
|
config.include EmailSpec::Helpers
|
11
8
|
config.include EmailSpec::Matchers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Mabey
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: htmlentities
|
@@ -227,6 +227,7 @@ files:
|
|
227
227
|
- examples/rails4_root/features/delayed_job.feature
|
228
228
|
- examples/rails4_root/features/errors.feature
|
229
229
|
- examples/rails4_root/features/example.feature
|
230
|
+
- examples/rails4_root/features/step_definitions/email_steps.rb
|
230
231
|
- examples/rails4_root/features/step_definitions/user_steps.rb
|
231
232
|
- examples/rails4_root/features/step_definitions/web_steps.rb
|
232
233
|
- examples/rails4_root/features/support/env.rb
|
@@ -260,6 +261,7 @@ files:
|
|
260
261
|
- examples/sinatra_root/config.ru
|
261
262
|
- examples/sinatra_root/features/errors.feature
|
262
263
|
- examples/sinatra_root/features/example.feature
|
264
|
+
- examples/sinatra_root/features/step_definitions/email_steps.rb
|
263
265
|
- examples/sinatra_root/features/step_definitions/user_steps.rb
|
264
266
|
- examples/sinatra_root/features/step_definitions/web_steps.rb
|
265
267
|
- examples/sinatra_root/features/support/env.rb
|
@@ -309,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
309
311
|
- !ruby/object:Gem::Version
|
310
312
|
version: '0'
|
311
313
|
requirements: []
|
312
|
-
rubygems_version: 3.
|
314
|
+
rubygems_version: 3.4.10
|
313
315
|
signing_key:
|
314
316
|
specification_version: 4
|
315
317
|
summary: Easily test email in RSpec, Cucumber or Minitest
|