From 1eb1871d433d1754dd7eab22d4864702f8da250b Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 17 Dec 2024 18:06:49 +0000 Subject: [PATCH] Skip signature verification if rspec-mocks is not loaded --- lib/rspec/rails/matchers/active_job.rb | 2 ++ spec/rspec/rails/matchers/active_job_spec.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/rspec/rails/matchers/active_job.rb b/lib/rspec/rails/matchers/active_job.rb index 1bdd323e5..f3da81e48 100644 --- a/lib/rspec/rails/matchers/active_job.rb +++ b/lib/rspec/rails/matchers/active_job.rb @@ -192,6 +192,8 @@ def detect_args_signature_mismatch(jobs) end def skip_signature_verification? + return true unless defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration)) + !RSpec::Mocks.configuration.verify_partial_doubles? || RSpec::Mocks.configuration.temporarily_suppress_partial_double_verification end diff --git a/spec/rspec/rails/matchers/active_job_spec.rb b/spec/rspec/rails/matchers/active_job_spec.rb index 5b299a28b..2111e3435 100644 --- a/spec/rspec/rails/matchers/active_job_spec.rb +++ b/spec/rspec/rails/matchers/active_job_spec.rb @@ -415,6 +415,18 @@ def perform; raise StandardError; end } end end + + context "without rspec-mocks loaded" do + before do + # Its hard for us to unload this, but its fairly safe to assume that we can run + # a defined? check, this just mocks the "short circuit" + allow(::RSpec::Mocks).to receive(:respond_to?).with(:configuration) { false } + end + + it "skips signature checks" do + expect { two_args_job.perform_later(1) }.to have_enqueued_job.with(1) + end + end end it "passes with provided arguments containing global id object" do