From 627a7a941b223a4d51bc894dd12bdfec26594a5e Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 10 Sep 2024 21:17:52 +0100 Subject: [PATCH] Add spec for arguments added in callbacks --- spec/rspec/rails/matchers/active_job_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/rspec/rails/matchers/active_job_spec.rb b/spec/rspec/rails/matchers/active_job_spec.rb index 86e191ae5..1a52e52ae 100644 --- a/spec/rspec/rails/matchers/active_job_spec.rb +++ b/spec/rspec/rails/matchers/active_job_spec.rb @@ -78,6 +78,17 @@ def self.name; "KeywordArgsJob"; end end end + let(:callback_job) do + Class.new(ActiveJob::Base) do + before_enqueue do |job| + job.arguments << 3 + end + + def perform(one, two); end + def self.name; "CallbackJob"; end + end + end + before do ActiveJob::Base.queue_adapter = :test end @@ -372,6 +383,12 @@ def perform; raise StandardError; end }.to have_enqueued_job.with(42, "David") end + it "will match arguments added in callbacks" do + expect { + callback_job.perform_later(1, 2) + }.to have_enqueued_job.with(1, 2, 3) + end + it "fails if the arguments do not match the job's signature" do expect { expect {