From 4ef17a81527bfdb328ddd68139460636a7a7b8bc Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 28 Oct 2022 17:10:35 -0400 Subject: [PATCH] Aggregate failures for flakey mailer specs [skip changelog] --- spec/support/mailer_helper.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spec/support/mailer_helper.rb b/spec/support/mailer_helper.rb index c36e60de0f3..388e912871a 100644 --- a/spec/support/mailer_helper.rb +++ b/spec/support/mailer_helper.rb @@ -17,14 +17,16 @@ def strip_tags(str) def expect_delivered_email(index, hash) mail = ActionMailer::Base.deliveries[index] - expect(mail.to).to eq hash[:to] if hash[:to] - expect(mail.subject).to eq hash[:subject] if hash[:subject] + aggregate_failures do + expect(mail.to).to eq hash[:to] if hash[:to] + expect(mail.subject).to eq hash[:subject] if hash[:subject] - if hash[:body] - delivered_body = mail.text_part.decoded.gsub("\r\n", ' ') - hash[:body].to_a.each do |expected_body| - expect(delivered_body).to include(expected_body) + if hash[:body] + delivered_body = mail.text_part.decoded.gsub("\r\n", ' ') + hash[:body].to_a.each do |expected_body| + expect(delivered_body).to include(expected_body) + end end end end