-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
RSpec leaks ActiveSupport::ExecutionContext between specs. #2644
Comments
A quick solution would be to What is interesting is that a new (can't find it in Rails 6.1 docs) option, Would you be interested in sending a PR, @BobbyMcWho ? |
@pirj I've been reviewing this for awhile now since I was trying to understand if this would affect our Rails 7 upgrade and to see about contributing a fix/update. But I had been going around in circles trying to understand why this isn't supported and resetting |
I believe that the best option here is reproducing the behavior of ActiveSupport::Executor::TestHelper / config.active_support.executor_around_test_case and wrapping every example by default with |
|
If someone wants to take up the executor thing you can see it currently blows up various job things for us in #2712, given I don't really know what it affects and most internal rails things will have their own I'm inclined to leave it for now |
@JonRowe I can take on the Executor wrap, thanks for linking to #2712. I'll make an issue to track it.
In Active Record, it will allow for the query cache to be enabled, it will also appropriately checkout and check-in database connections (and retry/recover from connection errors). Also, the executor will only be present for integration-like tests because the only places Rails will inserts executors is via a Rack Middleware, or when deserializing a job via |
Created #2713 |
Fix technically released in 6.0.4 but please use 6.1.0 for Rails 7.1 support. |
What Ruby, Rails and RSpec versions are you using?
Ruby version: 2.7
Rails version: 7.0.4
RSpec version: ~> 6.0
Observed behaviour
When using the Rails 7+ built in error reporter
Rails.error
, any context set during a spec leaks to the next spec.I've resolved this by
While this works for me, it feels like a tripping point for folks using rspec-rails on rails >= 7.0
Expected behaviour
ExecutionContext should be cleared between each spec, so that context does not leak between specs.
Can you provide an example app?
The text was updated successfully, but these errors were encountered: