Skip to content

Commit

Permalink
Merge pull request #2823 from rspec/ensure-mocks-config-available
Browse files Browse the repository at this point in the history
Ensure mocks config available
  • Loading branch information
JonRowe committed Feb 6, 2025
1 parent 3b099ce commit 7f63fa9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rspec/rails/matchers/active_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/rspec/rails/matchers/active_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f63fa9

Please sign in to comment.