Run RSpec in parallel with flatware
RSpec doesn't come with built-in parallelization like Minitest, but that doesn't mean you cannot parallize your test suite yourself with 3rd-party tools. One such a tool is Flatware.

Understanding Flatware and its purpose
Flatware is an innovative tool designed to enhance the efficiency of testing in Ruby on Rails applications by enabling parallel test execution. As Rails applications grow, so do their test suites, which can lead to longer testing times and slower feedback loops. This is where Flatware comes into play, offering a solution to speed up this process significantly.
Flatware allows developers to run tests concurrently, making optimal use of CPU resources. By dividing a test suite into smaller chunks that run simultaneously across multiple processing cores, Flatware reduces the overall time needed to execute the entire suite. This is particularly beneficial in continuous integration environments where rapid feedback is crucial.
Here's how the project README explains it:
Flatware relies on a message passing system to enable concurrency. The main process forks a worker for each cpu in the computer. These workers are each given a chunk of the tests to run. The workers report back to the main process about their progress. The main process prints those progress messages. When the last worker is finished the main process prints the results.
Setting up Flatware in Rails
Setting up Flatware in a Rails environment is a straightforward process that enhances your testing workflow by enabling parallel tests. Here’s a step-by-step guide to get you started. I'll only assume you already have RSpec configured in your Rails application.
Installation
To install Flatware, add it to your Gemfile. This ensures that it is included in your project's dependencies. Open your Gemfile and add:
gem 'flatware-rspec', require: false
There is also a support for Cucumber. If you are using it, add also flatware-cucumber.
Then, run the bundle command to install the new gem:
bundle install
Configuration
There is no specific Flatware configuration you need to do for a standard setup. Things will work automatically and Flatware will balance your worker setup. However you need to ensure you have more databases available:
# config/database.yml
test:
database: foo_test<%= ENV['TEST_ENV_NUMBER'] %>
Then you can run:
$ flatware fan rake db:test:prepare
Running tests
To execute your tests in parallel, use the following command:
$ flatware rspec
$ flatware cucumber
This command leverages Flatware's parallel processing capabilities, distributing RSpec tests across the specified number of workers. You can force number of workers with the -w option as flatware -w 3.