effective_test_bot 1.5.9 → 1.5.10
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 +20 -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: 5d6c35e391f98542191fd633aa5b1969e90657ceb2b5fe872e7735184c392a71
|
4
|
+
data.tar.gz: dcd72ecee5a4e73dfee52a068166010f54c1c30b96ca1305c88fbe824987d8ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38f0da58d5f36f2e45121ddcdf1adbd8bd2f022eb9bec14311f5951b24f9bcddb21a54c33f64d789d3b3d02987d7cb140cde357302b4cf5c6501cb6f6c6260a0
|
7
|
+
data.tar.gz: 4b1adb6b0a0ce8408f40fb0090b7646099925f887b2c6e0910798bb8601123f5c8dd83d02534b60a2720bed76cd1bf6293e85aa42314389aadcf4c456081bb5f
|
@@ -253,13 +253,16 @@ 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, to: nil, from: nil, subject: nil, body: nil, message: nil, count: nil, plain_layout: nil, html_layout: nil, &block)
|
257
257
|
retval = nil
|
258
258
|
|
259
259
|
# Clear the queue of any previous emails first
|
260
260
|
if perform
|
261
261
|
assert_email_perform_enqueued_jobs
|
262
262
|
raise('expected empty mailer queue. unable to clear it.') unless (assert_email_perform_enqueued_jobs.to_i == 0)
|
263
|
+
|
264
|
+
ActionMailer::Base.deliveries.clear
|
265
|
+
raise('expected empty mailer deliveries. unable to clear it.') unless (ActionMailer::Base.deliveries.length.to_i == 0)
|
263
266
|
end
|
264
267
|
|
265
268
|
before = ActionMailer::Base.deliveries.length
|
@@ -277,7 +280,7 @@ module EffectiveTestBotAssertions
|
|
277
280
|
end
|
278
281
|
end
|
279
282
|
|
280
|
-
if (action || to || from || subject || body).nil?
|
283
|
+
if (action || to || from || subject || body || plain_layout || html_layout).nil?
|
281
284
|
assert ActionMailer::Base.deliveries.present?, message || "(assert_email) Expected email to have been delivered"
|
282
285
|
return retval
|
283
286
|
end
|
@@ -287,11 +290,23 @@ module EffectiveTestBotAssertions
|
|
287
290
|
ActionMailer::Base.deliveries.each do |message|
|
288
291
|
matches = true
|
289
292
|
|
293
|
+
html_body = message.parts.find { |part| part.content_type.start_with?('text/html') }.try(:body).to_s.presence
|
294
|
+
plain_body = message.parts.find { |part| part.content_type.start_with?('text/plain') }.try(:body).to_s.presence
|
295
|
+
message_body = message.body.to_s
|
296
|
+
|
290
297
|
matches &&= (actions.include?(action.to_s)) if action
|
291
298
|
matches &&= (Array(message.to).include?(to)) if to
|
292
299
|
matches &&= (Array(message.from).include?(from)) if from
|
293
300
|
matches &&= (message.subject == subject) if subject
|
294
|
-
|
301
|
+
|
302
|
+
if body && html_layout
|
303
|
+
matches &&= html_body.to_s.gsub("\r\n", '').gsub("\n", '').include?(">#{body}<")
|
304
|
+
elsif body
|
305
|
+
matches &&= (plain_body == body || message_body == body)
|
306
|
+
end
|
307
|
+
|
308
|
+
matches &&= (html_body.present? && html_body.include?('<meta')) if html_layout
|
309
|
+
matches &&= (html_body.blank? && plain_body.blank? && message_body.exclude?('<meta')) if plain_layout
|
295
310
|
|
296
311
|
return retval if matches
|
297
312
|
end
|
@@ -302,6 +317,8 @@ module EffectiveTestBotAssertions
|
|
302
317
|
("from: {from}" if from),
|
303
318
|
("subject: #{subject}" if subject),
|
304
319
|
("body: #{body}" if body),
|
320
|
+
("an HTML layout" if html_layout),
|
321
|
+
("no HTML layout" if plain_layout),
|
305
322
|
].compact.to_sentence
|
306
323
|
|
307
324
|
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.10
|
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
|