Skip to content

Commit a43702d

Browse files
committed
Group job/mailer signature check specs
1 parent 1ba134d commit a43702d

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

spec/rspec/rails/matchers/active_job_spec.rb

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -372,20 +372,22 @@ def perform; raise StandardError; end
372372
}.to have_enqueued_job.with(42, "David")
373373
end
374374

375-
it "fails if the arguments do not match the job's signature" do
376-
expect {
375+
describe "verifying the arguments passed match the job's signature" do
376+
it "fails if there is an arity mismatch" do
377377
expect {
378-
two_args_job.perform_later(1)
379-
}.to have_enqueued_job.with(1)
380-
}.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/)
381-
end
378+
expect {
379+
two_args_job.perform_later(1)
380+
}.to have_enqueued_job.with(1)
381+
}.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/)
382+
end
382383

383-
it "fails if the job's signature/arguments are mismatched keyword/positional arguments" do
384-
expect {
384+
it "fails if there is a keyword/positional arguments mismatch" do
385385
expect {
386-
keyword_args_job.perform_later(1, 2)
387-
}.to have_enqueued_job.with(1, 2)
388-
}.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/)
386+
expect {
387+
keyword_args_job.perform_later(1, 2)
388+
}.to have_enqueued_job.with(1, 2)
389+
}.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/)
390+
end
389391
end
390392

391393
it "passes with provided arguments containing global id object" do
@@ -521,20 +523,22 @@ def perform; raise StandardError; end
521523
}.to fail_with(/expected to enqueue exactly 1 jobs, but enqueued 0/)
522524
end
523525

524-
it "fails if the arguments do not match the job's signature" do
525-
two_args_job.perform_later(1)
526+
describe "verifying the arguments passed match the job's signature" do
527+
it "fails if there is an arity mismatch" do
528+
two_args_job.perform_later(1)
526529

527-
expect {
528-
expect(two_args_job).to have_been_enqueued.with(1)
529-
}.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/)
530-
end
530+
expect {
531+
expect(two_args_job).to have_been_enqueued.with(1)
532+
}.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/)
533+
end
531534

532-
it "fails if the job's signature/arguments are mismatched keyword/positional arguments" do
533-
keyword_args_job.perform_later(1, 2)
535+
it "fails if there is a keyword/positional arguments mismatch" do
536+
keyword_args_job.perform_later(1, 2)
534537

535-
expect {
536-
expect(keyword_args_job).to have_been_enqueued.with(1, 2)
537-
}.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/)
538+
expect {
539+
expect(keyword_args_job).to have_been_enqueued.with(1, 2)
540+
}.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/)
541+
end
538542
end
539543

540544
it "fails when negated and several jobs enqueued" do

spec/rspec/rails/matchers/have_enqueued_mail_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,14 @@ def test_email; end
251251
}.not_to have_enqueued_mail(TestMailer, :email_with_args).with(3, 4)
252252
end
253253

254-
it "fails if the arguments do not match the mailer method's signature" do
255-
expect {
254+
describe "verifying the arguments passed match the mailer's signature" do
255+
it "fails if there is a mismatch" do
256256
expect {
257-
TestMailer.email_with_args(1).deliver_later
258-
}.to have_enqueued_mail(TestMailer, :email_with_args).with(1)
259-
}.to fail_with(/Incorrect arguments passed to TestMailer: Wrong number of arguments/)
257+
expect {
258+
TestMailer.email_with_args(1).deliver_later
259+
}.to have_enqueued_mail(TestMailer, :email_with_args).with(1)
260+
}.to fail_with(/Incorrect arguments passed to TestMailer: Wrong number of arguments/)
261+
end
260262
end
261263

262264
it "generates a failure message" do

0 commit comments

Comments
 (0)