Skip to content

Commit 5fead52

Browse files
authored
Merge pull request #2823 from rspec/ensure-mocks-config-available
Ensure mocks config available
2 parents 1965116 + 1eb1871 commit 5fead52

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/rspec/rails/matchers/active_job.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ def detect_args_signature_mismatch(jobs)
192192
end
193193

194194
def skip_signature_verification?
195+
return true unless defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration))
196+
195197
!RSpec::Mocks.configuration.verify_partial_doubles? ||
196198
RSpec::Mocks.configuration.temporarily_suppress_partial_double_verification
197199
end

spec/rspec/rails/matchers/active_job_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,18 @@ def perform; raise StandardError; end
415415
}
416416
end
417417
end
418+
419+
context "without rspec-mocks loaded" do
420+
before do
421+
# Its hard for us to unload this, but its fairly safe to assume that we can run
422+
# a defined? check, this just mocks the "short circuit"
423+
allow(::RSpec::Mocks).to receive(:respond_to?).with(:configuration) { false }
424+
end
425+
426+
it "skips signature checks" do
427+
expect { two_args_job.perform_later(1) }.to have_enqueued_job.with(1)
428+
end
429+
end
418430
end
419431

420432
it "passes with provided arguments containing global id object" do

0 commit comments

Comments
 (0)