This generator configures your Rails application to run RSpec tests in parallel, greatly reducing the time it takes to run your test suite.
The generator will add the parallel_tests, turbo_tests, and rspec_junit_formatter gems to your Gemfile and run bundle install.
group :development, :test do
gem 'parallel_tests'
gem 'turbo_tests', require: false
gem 'rspec_junit_formatter', require: false
endThe generator will create a .rspec_parallel file in your Rails root directory.
--format RspecJunitFormatter --out tmp/rspec-<%= ENV['TEST_ENV_NUMBER'] %>.xml
--format ParallelTests::RSpec::RuntimeLogger --out tmp/turbo_rspec_runtime.log
--format ParallelTests::RSpec::FailuresLogger
Your database.yml will be updated to support parallel test databases. This allows each test process to use its own isolated database.
test:
# ...existing configuration...
database: your_app_test<%= ENV['TEST_ENV_NUMBER'] %>Once configured, you can run your tests in parallel using:
# Run entire test suite in parallel
bundle exec rake parallel:spec
# Run specific tests in parallel
bundle exec rake parallel:spec[spec/models]
# Specify number of processes (default is the number of CPUs)
bundle exec rake parallel:spec[spec,4]