Skip to content

Commit ded3cfa

Browse files
fabnpirj
authored andcommitted
Ensure ActionMailer::MailDeliveryJob is defined
1 parent c3979eb commit ded3cfa

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/rspec/rails/matchers/have_enqueued_mail.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ def arguments_match?(job)
8989
end
9090

9191
def process_arguments(job, given_mail_args)
92-
if job[:job] == ActionMailer::MailDeliveryJob
93-
if given_mail_args.first.is_a?(Hash) && job[:args][3]['params'].present?
94-
[hash_including(params: given_mail_args[0], args: given_mail_args.drop(1))]
95-
else
96-
[hash_including(args: given_mail_args)]
97-
end
92+
# Old matcher behavior working with all builtin classes but ActionMailer::MailDeliveryJob
93+
return given_mail_args unless defined?(ActionMailer::MailDeliveryJob) && job[:job] <= ActionMailer::MailDeliveryJob
94+
95+
# If matching args starts with a hash and job instance has params match with them
96+
if given_mail_args.first.is_a?(Hash) && job[:args][3]['params'].present?
97+
[hash_including(params: given_mail_args[0], args: given_mail_args.drop(1))]
9898
else
99-
given_mail_args
99+
[hash_including(args: given_mail_args)]
100100
end
101101
end
102102

0 commit comments

Comments
 (0)