Skip to content

Commit c8cc534

Browse files
author
Joel Lubrano
committed
Only pass a mailer-specific block to super if a block is provided
1 parent c5b5895 commit c8cc534

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/rspec/rails/matchers/have_enqueued_mail.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ def description
2828

2929
def with(*args, &block)
3030
@mail_args = args
31-
32-
super(*mailer_args) do |*job_args|
33-
block.call(*(job_args - base_mailer_args)) if block.present?
34-
end
31+
block.nil? ? super(*mailer_args) : super(*mailer_args, &yield_mail_args(block))
3532
end
3633

3734
def matches?(block)
@@ -86,6 +83,10 @@ def base_mailer_args
8683
[@mailer_class.name, @method_name.to_s, MAILER_JOB_METHOD]
8784
end
8885

86+
def yield_mail_args(block)
87+
Proc.new { |*job_args| block.call(*(job_args - base_mailer_args)) }
88+
end
89+
8990
def check_active_job_adapter
9091
return if ::ActiveJob::QueueAdapters::TestAdapter === ::ActiveJob::Base.queue_adapter
9192
raise StandardError, "To use HaveEnqueuedMail matcher set `ActiveJob::Base.queue_adapter = :test`"

0 commit comments

Comments
 (0)