From b430027965a8544606c337063e256053b0f1cd68 Mon Sep 17 00:00:00 2001 From: Javier Julio Date: Sat, 6 Apr 2024 10:42:26 -0400 Subject: [PATCH] Wrap examples with Rails executor This recreates #2712 since the GHA logs are no longer available which we need to address this issue. We should be wrapping the Rails examples with the executor to mimic what Rails v7 does (as noted in #2713) to properly reset state. This has been tested in a test suite for an app but we need to address what issues there is within rspec-rails. This change request originated from #2503 and #2752 which the latter is meant as a temporary fix since this is the expected way to reset state. --- lib/rspec/rails/example/rails_example_group.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/rspec/rails/example/rails_example_group.rb b/lib/rspec/rails/example/rails_example_group.rb index ed343de35..ff0fba53b 100644 --- a/lib/rspec/rails/example/rails_example_group.rb +++ b/lib/rspec/rails/example/rails_example_group.rb @@ -2,11 +2,6 @@ # suite and ammeter. require 'rspec/rails/matchers' -if ::Rails::VERSION::MAJOR >= 7 - require 'active_support/current_attributes/test_helper' - require 'active_support/execution_context/test_helper' -end - module RSpec module Rails # @api public @@ -17,10 +12,16 @@ module RailsExampleGroup include RSpec::Rails::MinitestLifecycleAdapter include RSpec::Rails::MinitestAssertionAdapter include RSpec::Rails::FixtureSupport + include RSpec::Rails::TaggedLoggingAdapter if ::Rails::VERSION::MAJOR >= 7 + if ::Rails::VERSION::MAJOR >= 7 include RSpec::Rails::TaggedLoggingAdapter - include ActiveSupport::CurrentAttributes::TestHelper include ActiveSupport::ExecutionContext::TestHelper + included do |_other| + around do |example| + ::Rails.application.executor.perform { example.call } + end + end end end end