effective_test_bot 1.5.9 → 1.5.11
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/lib/effective_test_bot/version.rb +1 -1
- data/test/support/effective_test_bot_assertions.rb +23 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff3684f4325c106f954588537160bf2adb098f279cef78bda3973c3e7ed6b518
|
4
|
+
data.tar.gz: 1c46b71f6cb039f06433fc2577ed02d74e075b90774b4cd37c4170e82e0f75fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51f8ee341063d10213250224a5266d46ce2ac8dcf05e123c5d53afb0ef1b0c5dcde375cea28596c17b656007787d78222dc2ee9d6a824b361b087e25cdf72de3
|
7
|
+
data.tar.gz: 5d4790594fa21013f9f44c5cf5b9b2ac946394d887efc02c813ee992fb4268832eeee0824ad33db7a2732ad5fdc338f5954e47210c8e4bf539e2967f1e76e760
|
@@ -253,8 +253,9 @@ module EffectiveTestBotAssertions
|
|
253
253
|
# assert_email :new_user_sign_up
|
254
254
|
# assert_email :new_user_sign_up, to: 'newuser@example.com'
|
255
255
|
# assert_email from: 'admin@example.com'
|
256
|
-
def assert_email(action = nil, perform: true, to: nil, from: nil, subject: nil, body: nil, message: nil, count: nil, &block)
|
256
|
+
def assert_email(action = nil, perform: true, clear: nil, to: nil, from: nil, subject: nil, body: nil, message: nil, count: nil, plain_layout: nil, html_layout: nil, &block)
|
257
257
|
retval = nil
|
258
|
+
clear = (count || 0) < 2 if clear.nil?
|
258
259
|
|
259
260
|
# Clear the queue of any previous emails first
|
260
261
|
if perform
|
@@ -262,6 +263,11 @@ module EffectiveTestBotAssertions
|
|
262
263
|
raise('expected empty mailer queue. unable to clear it.') unless (assert_email_perform_enqueued_jobs.to_i == 0)
|
263
264
|
end
|
264
265
|
|
266
|
+
if clear
|
267
|
+
ActionMailer::Base.deliveries.clear
|
268
|
+
raise('expected empty mailer deliveries. unable to clear it.') unless (ActionMailer::Base.deliveries.length.to_i == 0)
|
269
|
+
end
|
270
|
+
|
265
271
|
before = ActionMailer::Base.deliveries.length
|
266
272
|
|
267
273
|
if block_given?
|
@@ -277,7 +283,7 @@ module EffectiveTestBotAssertions
|
|
277
283
|
end
|
278
284
|
end
|
279
285
|
|
280
|
-
if (action || to || from || subject || body).nil?
|
286
|
+
if (action || to || from || subject || body || plain_layout || html_layout).nil?
|
281
287
|
assert ActionMailer::Base.deliveries.present?, message || "(assert_email) Expected email to have been delivered"
|
282
288
|
return retval
|
283
289
|
end
|
@@ -287,11 +293,23 @@ module EffectiveTestBotAssertions
|
|
287
293
|
ActionMailer::Base.deliveries.each do |message|
|
288
294
|
matches = true
|
289
295
|
|
296
|
+
html_body = message.parts.find { |part| part.content_type.start_with?('text/html') }.try(:body).to_s.presence
|
297
|
+
plain_body = message.parts.find { |part| part.content_type.start_with?('text/plain') }.try(:body).to_s.presence
|
298
|
+
message_body = message.body.to_s
|
299
|
+
|
290
300
|
matches &&= (actions.include?(action.to_s)) if action
|
291
301
|
matches &&= (Array(message.to).include?(to)) if to
|
292
302
|
matches &&= (Array(message.from).include?(from)) if from
|
293
303
|
matches &&= (message.subject == subject) if subject
|
294
|
-
|
304
|
+
|
305
|
+
if body && html_layout
|
306
|
+
matches &&= html_body.to_s.gsub("\r\n", '').gsub("\n", '').include?(">#{body}<")
|
307
|
+
elsif body
|
308
|
+
matches &&= (plain_body == body || message_body == body)
|
309
|
+
end
|
310
|
+
|
311
|
+
matches &&= (html_body.present? && html_body.include?('<meta')) if html_layout
|
312
|
+
matches &&= (html_body.blank? && plain_body.blank? && message_body.exclude?('<meta')) if plain_layout
|
295
313
|
|
296
314
|
return retval if matches
|
297
315
|
end
|
@@ -302,6 +320,8 @@ module EffectiveTestBotAssertions
|
|
302
320
|
("from: {from}" if from),
|
303
321
|
("subject: #{subject}" if subject),
|
304
322
|
("body: #{body}" if body),
|
323
|
+
("an HTML layout" if html_layout),
|
324
|
+
("no HTML layout" if plain_layout),
|
305
325
|
].compact.to_sentence
|
306
326
|
|
307
327
|
assert false, message || "(assert_email) Expected email with #{expected} to have been delivered"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_test_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|