test_assistant 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_assistant/email/expectation.rb +4 -3
- data/lib/test_assistant/version.rb +1 -1
- data/spec/email_expectation_spec.rb +21 -21
- data/spec/support/email_mock.rb +9 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfe1610c486eff9f3ad4683799bcfc91c861c7f5
|
4
|
+
data.tar.gz: 8bc9686c28979433d3e17fed24f983dc72fc104c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca6bb85a6d11ebda0f0d5ac40695a7dee8fd3d2863b3c2d13f5f9c2667c05ec95d09d61efe9a08d3100f847e8ee73ef355dc0e7e0b83bc861cfb04a6dea085f0
|
7
|
+
data.tar.gz: dc90720582c1a364ad13a17e4aa65e578616e71e0a6dcae9ed9d00450d9aba8bc4b1a461880872a1fbdc24c489285c5afb34d15969387f2dc503346e196db9a0
|
@@ -208,7 +208,7 @@ module TestAssistant::Email
|
|
208
208
|
matcher[:actual].(email, parsed_emails(email))
|
209
209
|
end
|
210
210
|
|
211
|
-
value = value.kind_of?(String) ? "'#{value}'" : value
|
211
|
+
value = value.kind_of?(String) ? "'#{value}'" : value.map{|element| "'#{element}'"}
|
212
212
|
memo << value
|
213
213
|
end
|
214
214
|
|
@@ -299,11 +299,12 @@ module TestAssistant::Email
|
|
299
299
|
end
|
300
300
|
|
301
301
|
def email_matches?(email, assertion, expected)
|
302
|
+
|
302
303
|
case assertion
|
303
304
|
when :to
|
304
|
-
expected
|
305
|
+
(expected & email.send(assertion)).length > 0
|
305
306
|
when String, Symbol
|
306
|
-
|
307
|
+
email.send(assertion).include?(expected)
|
307
308
|
when Hash
|
308
309
|
assertion[:match].(email, parsed_emails(email), expected)
|
309
310
|
else
|
@@ -84,26 +84,26 @@ RSpec.describe 'have_sent_email' do
|
|
84
84
|
|
85
85
|
it "then a positive 'to' assertion passes" do
|
86
86
|
expect {
|
87
|
-
expect(subject).to have_been_sent.to(subject[0].to)
|
87
|
+
expect(subject).to have_been_sent.to(subject[0].to[0])
|
88
88
|
}.to_not raise_error
|
89
89
|
end
|
90
90
|
|
91
91
|
it "then a negative 'to' assertion fails" do
|
92
92
|
expect {
|
93
|
-
expect(subject).to_not have_been_sent.to(subject[0].to)
|
94
|
-
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[0].to}'.")
|
93
|
+
expect(subject).to_not have_been_sent.to(subject[0].to[0])
|
94
|
+
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[0].to[0]}'.")
|
95
95
|
end
|
96
96
|
|
97
97
|
it "then a positive 'from' assertion passes" do
|
98
98
|
expect {
|
99
|
-
expect(subject).to have_been_sent.from(subject[0].from)
|
99
|
+
expect(subject).to have_been_sent.from(subject[0].from[0])
|
100
100
|
}.to_not raise_error
|
101
101
|
end
|
102
102
|
|
103
103
|
it "then a negative 'from' assertion fails" do
|
104
104
|
expect {
|
105
|
-
expect(subject).to_not have_been_sent.from(subject[0].from)
|
106
|
-
}.to raise_error.with_message("Expected no emails to be sent from '#{subject[0].from}'.")
|
105
|
+
expect(subject).to_not have_been_sent.from(subject[0].from[0])
|
106
|
+
}.to raise_error.with_message("Expected no emails to be sent from '#{subject[0].from[0]}'.")
|
107
107
|
end
|
108
108
|
|
109
109
|
it "then a positive 'with_subject' assertion passes" do
|
@@ -173,7 +173,7 @@ RSpec.describe 'have_sent_email' do
|
|
173
173
|
it "then a positive 'to' assertion fails" do
|
174
174
|
expect {
|
175
175
|
expect(subject).to have_been_sent.to('other@email.com')
|
176
|
-
}.to raise_error.with_message("Expected an email to be sent to 'other@email.com'. However, 1 was sent to '#{subject[0].to}'.")
|
176
|
+
}.to raise_error.with_message("Expected an email to be sent to 'other@email.com'. However, 1 was sent to '#{subject[0].to[0]}'.")
|
177
177
|
end
|
178
178
|
|
179
179
|
it "then a negative 'to' assertion passes" do
|
@@ -185,7 +185,7 @@ RSpec.describe 'have_sent_email' do
|
|
185
185
|
it "then a positive 'from' assertion fails" do
|
186
186
|
expect {
|
187
187
|
expect(subject).to have_been_sent.from('other@email.com')
|
188
|
-
}.to raise_error.with_message("Expected an email to be sent from 'other@email.com'. However, 1 was sent from '#{subject[0].from}'.")
|
188
|
+
}.to raise_error.with_message("Expected an email to be sent from 'other@email.com'. However, 1 was sent from '#{subject[0].from[0]}'.")
|
189
189
|
end
|
190
190
|
|
191
191
|
it "then a negative 'from' assertion passes" do
|
@@ -260,14 +260,14 @@ RSpec.describe 'have_sent_email' do
|
|
260
260
|
|
261
261
|
it "then a positive assertion matching the first email passes" do
|
262
262
|
expect {
|
263
|
-
expect(subject).to have_been_sent.to(subject[0].to)
|
263
|
+
expect(subject).to have_been_sent.to(subject[0].to[0])
|
264
264
|
}.to_not raise_error
|
265
265
|
end
|
266
266
|
|
267
267
|
it "then a negative assertion matching the first email fails" do
|
268
268
|
expect {
|
269
|
-
expect(subject).to_not have_been_sent.to(subject[0].to)
|
270
|
-
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[0].to}'.")
|
269
|
+
expect(subject).to_not have_been_sent.to(subject[0].to[0])
|
270
|
+
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[0].to[0]}'.")
|
271
271
|
end
|
272
272
|
|
273
273
|
it "then a positive assertion matching the second email passes" do
|
@@ -279,7 +279,7 @@ RSpec.describe 'have_sent_email' do
|
|
279
279
|
it "then a negative assertion matching the second email fails" do
|
280
280
|
expect {
|
281
281
|
expect(subject).to_not have_been_sent.to(subject[1].to)
|
282
|
-
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[1].to}'.")
|
282
|
+
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[1].to[0]}'.")
|
283
283
|
end
|
284
284
|
|
285
285
|
end
|
@@ -289,37 +289,37 @@ RSpec.describe 'have_sent_email' do
|
|
289
289
|
|
290
290
|
it "then a positive assertions correctly matches a matching email" do
|
291
291
|
expect {
|
292
|
-
expect(subject).to have_been_sent.to(subject[0].to).from(subject[0].from)
|
292
|
+
expect(subject).to have_been_sent.to(subject[0].to[0]).from(subject[0].from[0])
|
293
293
|
}.to_not raise_error
|
294
294
|
end
|
295
295
|
|
296
296
|
it "then a positive assertions don't match an email if the first qualifier isn't satisfied" do
|
297
297
|
expect {
|
298
|
-
expect(subject).to have_been_sent.to('other@email.com').from(subject[0].from)
|
299
|
-
}.to raise_error.with_message("Expected an email to be sent to 'other@email.com'. However, 1 was sent to '#{subject[0].to}'.")
|
298
|
+
expect(subject).to have_been_sent.to('other@email.com').from(subject[0].from[0])
|
299
|
+
}.to raise_error.with_message("Expected an email to be sent to 'other@email.com'. However, 1 was sent to '#{subject[0].to[0]}'.")
|
300
300
|
end
|
301
301
|
|
302
302
|
it "then a positive assertions don't match an email if the last qualifier isn't satisfied" do
|
303
303
|
expect {
|
304
|
-
expect(subject).to have_been_sent.to(subject[0].to).from('other@email.com')
|
305
|
-
}.to raise_error.with_message("Expected an email to be sent from 'other@email.com'. However, 1 was sent from '#{subject[0].from}'.")
|
304
|
+
expect(subject).to have_been_sent.to(subject[0].to[0]).from('other@email.com')
|
305
|
+
}.to raise_error.with_message("Expected an email to be sent from 'other@email.com'. However, 1 was sent from '#{subject[0].from[0]}'.")
|
306
306
|
end
|
307
307
|
|
308
308
|
it "then a negative assertions correctly matches a matching email" do
|
309
309
|
expect {
|
310
|
-
expect(subject).to_not have_been_sent.to(subject[0].to).from(subject[0].from)
|
311
|
-
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[0].to}' from '#{subject[0].from}'.")
|
310
|
+
expect(subject).to_not have_been_sent.to(subject[0].to[0]).from(subject[0].from[0])
|
311
|
+
}.to raise_error.with_message("Expected no emails to be sent to '#{subject[0].to[0]}' from '#{subject[0].from[0]}'.")
|
312
312
|
end
|
313
313
|
|
314
314
|
it "then a negative assertions don't match an email if the first qualifier isn't satisfied" do
|
315
315
|
expect {
|
316
|
-
expect(subject).to_not have_been_sent.to('other@email.com').from(subject[0].from)
|
316
|
+
expect(subject).to_not have_been_sent.to('other@email.com').from(subject[0].from[0])
|
317
317
|
}.to_not raise_error
|
318
318
|
end
|
319
319
|
|
320
320
|
it "then a negative assertions don't match an email if the last qualifier isn't satisfied" do
|
321
321
|
expect {
|
322
|
-
expect(subject).to_not have_been_sent.to(subject[0].to).from('other@email.com')
|
322
|
+
expect(subject).to_not have_been_sent.to(subject[0].to[0]).from('other@email.com')
|
323
323
|
}.to_not raise_error
|
324
324
|
end
|
325
325
|
end
|
data/spec/support/email_mock.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class EmailMock
|
2
|
-
attr_reader :
|
2
|
+
attr_reader :subject, :text, :body
|
3
3
|
|
4
4
|
def initialize(to: 'receiver@email.com', from: 'sender@email.com', subject: 'Subject', text: 'Test Email', body: "<body><h1>Test Email</h1><a href='www.test.com' /><img src='www.test.com' /></body>")
|
5
5
|
@to, @from, @subject, @text, @body = to, from, subject, text, body
|
@@ -10,6 +10,14 @@ class EmailMock
|
|
10
10
|
EmailBodyMock.new(@body)
|
11
11
|
]
|
12
12
|
end
|
13
|
+
|
14
|
+
def to
|
15
|
+
[ @to ]
|
16
|
+
end
|
17
|
+
|
18
|
+
def from
|
19
|
+
[ @from ]
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
23
|
class EmailBodyMock
|