@@ -243,6 +243,14 @@ def test_email; end
243
243
} . not_to have_enqueued_mail ( TestMailer , :email_with_args ) . with ( 3 , 4 )
244
244
end
245
245
246
+ it "fails if the arguments do not match the mailer method's signature" do
247
+ expect {
248
+ expect {
249
+ TestMailer . email_with_args ( 1 ) . deliver_later
250
+ } . to have_enqueued_mail ( TestMailer , :email_with_args ) . with ( 1 )
251
+ } . to raise_error ( ArgumentError , /Wrong number of arguments/ )
252
+ end
253
+
246
254
it "generates a failure message" do
247
255
expect {
248
256
expect { } . to have_enqueued_email ( TestMailer , :test_email )
@@ -388,6 +396,14 @@ def self.name; "NonMailerJob"; end
388
396
TestMailer . with ( 'foo' => 'bar' ) . email_with_args ( 1 , 2 ) . deliver_later
389
397
} . to have_enqueued_mail ( TestMailer , :email_with_args ) . with ( { 'foo' => 'bar' } , 1 , 2 )
390
398
end
399
+
400
+ it "fails if the arguments do not match the mailer method's signature" do
401
+ expect {
402
+ expect {
403
+ TestMailer . with ( 'foo' => 'bar' ) . email_with_args ( 1 ) . deliver_later
404
+ } . to have_enqueued_mail ( TestMailer , :email_with_args ) . with ( { 'foo' => 'bar' } , 1 )
405
+ } . to raise_error ( ArgumentError , /Wrong number of arguments/ )
406
+ end
391
407
end
392
408
393
409
context 'mailer job is unified' , skip : !RSpec ::Rails ::FeatureCheck . has_action_mailer_unified_delivery? do
@@ -435,6 +451,16 @@ def self.name; "NonMailerJob"; end
435
451
UnifiedMailerWithDeliveryJobSubClass . test_email . deliver_later
436
452
} . to have_enqueued_mail ( UnifiedMailerWithDeliveryJobSubClass , :test_email )
437
453
end
454
+
455
+ it "fails if the arguments do not match the mailer method's signature" do
456
+ expect {
457
+ expect {
458
+ UnifiedMailer . with ( 'foo' => 'bar' ) . email_with_args ( 1 ) . deliver_later
459
+ } . to have_enqueued_mail ( UnifiedMailer , :email_with_args ) . with (
460
+ a_hash_including ( params : { 'foo' => 'bar' } , args : [ 1 ] )
461
+ )
462
+ } . to raise_error ( ArgumentError , /Wrong number of arguments/ )
463
+ end
438
464
end
439
465
end
440
466
end
0 commit comments