diff --git a/guides/source/testing.md b/guides/source/testing.md index 30d5bc9cf3..1187b6c183 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -535,7 +535,7 @@ class ActiveSupport::TestCase end ``` -Rails applications generated from JRuby will automatically include the `with: :threads` option. +Rails applications generated from JRuby or TruffleRuby will automatically include the `with: :threads` option. The number of workers passed to `parallelize` determines the number of threads the tests will use. You may want to parallelize your local test suite differently from your CI, so an environment variable is provided diff --git a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt index cc677ab411..472c9a7739 100644 --- a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt @@ -4,10 +4,10 @@ require "rails/test_help" class ActiveSupport::TestCase # Run tests in parallel with specified workers -<% if defined?(JRUBY_VERSION) || Gem.win_platform? -%> - parallelize(workers: :number_of_processors, with: :threads) -<%- else -%> +<% if Process.respond_to?(:fork) && !Gem.win_platform? -%> parallelize(workers: :number_of_processors) +<%- else -%> + parallelize(workers: :number_of_processors, with: :threads) <% end -%> <% unless options[:skip_active_record] -%> diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 3277b70406..94baa2d7ab 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -862,7 +862,7 @@ def test_spring_binstubs def test_spring_no_fork jruby_skip "spring doesn't run on JRuby" - assert_called_with(Process, :respond_to?, [[:fork], [:fork], [:fork]], returns: false) do + assert_called_with(Process, :respond_to?, [[:fork], [:fork], [:fork], [:fork]], returns: false) do run_generator assert_no_gem "spring"