Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap examples with Rails executor #2713

Open
bensheldon opened this issue Nov 16, 2023 · 2 comments
Open

Wrap examples with Rails executor #2713

bensheldon opened this issue Nov 16, 2023 · 2 comments

Comments

@bensheldon
Copy link

Describe the solution you'd like

In #2644, Execution Contexts were cleared, but did not go to fully wrapping specs with a Rails Executor. In the current version of Rails (7.1) TestCases look like this:

ActiveSupport.on_load(:active_support_test_case) do
  if app.config.active_support.executor_around_test_case
    require "active_support/executor/test_helper"
    include ActiveSupport::Executor::TestHelper
  else
    require "active_support/current_attributes/test_helper"
    include ActiveSupport::CurrentAttributes::TestHelper

    require "active_support/execution_context/test_helper"
    include ActiveSupport::ExecutionContext::TestHelper
  end
end

...and it would be nice if rspec-rails offered that too of using ActiveSupport::Executor::TestHelper

@JonRowe
Copy link
Member

JonRowe commented Nov 17, 2023

See also #2712 for build failures attempting this caused.

javierjulio added a commit to javierjulio/rspec-rails that referenced this issue Apr 6, 2024
This recreates rspec#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 rspec#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 rspec#2503 and rspec#2752 which the latter is meant as a temporary fix since this is the expected way to reset state.
@javierjulio
Copy link
Contributor

javierjulio commented Apr 6, 2024

I found my way here for the CurrentAttributes reset portion but seems several of these things are tied together. Worth noting that even with a rails spec type (e.g. type: :request) CurrentAttributes are not reset in rspec-rails. I've created #2752 and #2753 to help address this. The former is a temporary fix considering the current state of the RailsExampleGroup to match what Rails does for that condition. It will reset CurrentAttributes for each example. The ideal fix is in the latter which should use either the executor or the individual test helpers like noted in the description here.

JonRowe pushed a commit to javierjulio/rspec-rails that referenced this issue Apr 10, 2024
This recreates rspec#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 rspec#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 rspec#2503 and rspec#2752 which the latter is meant as a temporary fix since this is the expected way to reset state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants