From fa3806dd7311d29e12229a787ed1043acd9c66c0 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 0643b9ae1..fc5ec75da 100644 --- a/lib/rspec/rails/example/rails_example_group.rb +++ b/lib/rspec/rails/example/rails_example_group.rb @@ -2,10 +2,6 @@ # suite and ammeter. require 'rspec/rails/matchers' -if ::Rails::VERSION::MAJOR >= 7 - require 'active_support/execution_context/test_helper' -end - module RSpec module Rails # @api public @@ -16,9 +12,14 @@ 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::ExecutionContext::TestHelper + included do |_other| + around do |example| + ::Rails.application.executor.perform { example.call } + end + end end end end