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 tests in executor when configured or on Rails 7 by default #2712

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/rspec/rails/example/rails_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ module RailsExampleGroup
include RSpec::Rails::MinitestAssertionAdapter
include RSpec::Rails::FixtureSupport
include RSpec::Rails::TaggedLoggingAdapter if ::Rails::VERSION::MAJOR >= 7

included do |_other|
around do |example|
use_exectuor =
case ::Rails.configuration.active_support.executor_around_test_case
when nil then ::Rails::VERSION::MAJOR >= 7
when true then true
when false then false
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to do this. "Default in Rails 7" means it is set as true when calling config.load_defaults 7.0. Otherwise, it should stay disabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean it’s unnecessary to default to true on Rails 7, and it’s sufficient to just?

use_exectuor = ::Rails.configuration.active_support.executor_around_test_case

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if use_exectuor
::Rails.application.executor.perform { example.call }
else
example.call
end
end
end
end
end
end
Loading