11require "rspec/rails/feature_check"
2- require "support/temporary_assignment"
32
43if RSpec ::Rails ::FeatureCheck . has_active_job?
54 require "rspec/rails/matchers/active_job"
@@ -35,7 +34,6 @@ def self.find(_id)
3534
3635RSpec . describe "ActiveJob matchers" , skip : !RSpec ::Rails ::FeatureCheck . has_active_job? do
3736 include ActiveSupport ::Testing ::TimeHelpers
38- include TemporaryAssignment
3937
4038 around do |example |
4139 original_logger = ActiveJob ::Base . logger
@@ -44,6 +42,13 @@ def self.find(_id)
4442 ActiveJob ::Base . logger = original_logger
4543 end
4644
45+ around do |example |
46+ original_value = RSpec ::Mocks . configuration . verify_partial_doubles?
47+ example . run
48+ ensure
49+ RSpec ::Mocks . configuration . verify_partial_doubles = original_value
50+ end
51+
4752 let ( :heavy_lifting_job ) do
4853 Class . new ( ActiveJob ::Base ) do
4954 def perform ; end
@@ -392,10 +397,12 @@ def perform; raise StandardError; end
392397 end
393398
394399 context "with partial double verification disabled" do
400+ before do
401+ RSpec ::Mocks . configuration . verify_partial_doubles = false
402+ end
403+
395404 it "skips signature checks" do
396- with_temporary_assignment ( RSpec ::Mocks . configuration , :verify_partial_doubles , false ) {
397- expect { two_args_job . perform_later ( 1 ) } . to have_enqueued_job . with ( 1 )
398- }
405+ expect { two_args_job . perform_later ( 1 ) } . to have_enqueued_job . with ( 1 )
399406 end
400407 end
401408
@@ -561,12 +568,14 @@ def perform; raise StandardError; end
561568 end
562569
563570 context "with partial double verification disabled" do
571+ before do
572+ RSpec ::Mocks . configuration . verify_partial_doubles = false
573+ end
574+
564575 it "skips signature checks" do
565576 keyword_args_job . perform_later ( 1 , 2 )
566577
567- with_temporary_assignment ( RSpec ::Mocks . configuration , :verify_partial_doubles , false ) {
568- expect ( keyword_args_job ) . to have_been_enqueued . with ( 1 , 2 )
569- }
578+ expect ( keyword_args_job ) . to have_been_enqueued . with ( 1 , 2 )
570579 end
571580 end
572581
0 commit comments