### Installing Flatware Gems (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md After adding the gems to your Gemfile, run `bundle install` to download and install them into your project's bundle. ```sh bundle install ``` -------------------------------- ### Preparing Parallel Test Databases (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md Run `rake db:setup` once, then use `flatware fan rake db:test:prepare` to prepare the databases for each parallel worker. ```sh $ rake db:setup # if not already done ``` ```sh $ flatware fan rake db:test:prepare ``` -------------------------------- ### Configuring Flatware Lifecycle Hooks for ActiveRecord (Ruby) Source: https://github.com/briandunn/flatware/blob/master/README.md Define `before_fork` and `after_fork` hooks in a file like `spec/flatware_helper.rb` to manage ActiveRecord connections across parallel workers, preventing issues like segmentation faults and ensuring each worker connects to its unique test database. Includes commented-out examples for PG gem fix and SimpleCov integration. ```ruby ## # uncomment if you get a segmentation fault from the "pg" gem # @see https://github.com/ged/ruby-pg/issues/311#issuecomment-1609970533 # ENV["PGGSSENCMODE"] = "disable" Flatware.configure do |conf| conf.before_fork do require 'rails_helper' ActiveRecord::Base.connection.disconnect! end conf.after_fork do |test_env_number| ## # uncomment if you're using SimpleCov and have started it in `rails_helper` as suggested here: # @see https://github.com/simplecov-ruby/simplecov/tree/main?tab=readme-ov-file#use-it-with-any-framework # SimpleCov.at_fork.call(test_env_number) config = ActiveRecord::Base.connection_db_config.configuration_hash ActiveRecord::Base.establish_connection( config.merge( database: config.fetch(:database) + test_env_number.to_s ) ) end end ``` -------------------------------- ### Passing Options to Flatware Cucumber (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md Pass standard Cucumber options directly to Flatware to filter or modify test execution, for example, excluding features tagged 'javascript'. ```sh $ flatware cucumber -t 'not @javascript' ``` -------------------------------- ### Running RSpec Suite with Flatware (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md Execute your entire RSpec test suite in parallel using Flatware with default options. ```sh $ flatware rspec ``` -------------------------------- ### Configuring RSpec for Worker Balancing (RSpec Config) Source: https://github.com/briandunn/flatware/blob/master/README.md Include this line in your `.rspec` file to require `spec_helper` before specs run, which is necessary for Flatware's worker balancing feature based on test run times. ```text --require spec_helper ``` -------------------------------- ### Adding Flatware Gems to Gemfile (Ruby) Source: https://github.com/briandunn/flatware/blob/master/README.md Add the necessary Flatware gems (`flatware-rspec`, `flatware-cucumber`) to your project's Gemfile to enable parallel test execution. Use `require: false` as they are command-line tools. ```ruby gem 'flatware-rspec', require: false # one gem 'flatware-cucumber', require: false # or both ``` -------------------------------- ### Running Cucumber Suite with Flatware (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md Execute your entire Cucumber test suite in parallel using Flatware with default options. ```sh $ flatware cucumber ``` -------------------------------- ### Modifying database.yml for Parallel Tests (YAML) Source: https://github.com/briandunn/flatware/blob/master/README.md Modify your `test` database configuration in `config/database.yml` to append the `TEST_ENV_NUMBER` environment variable, allowing each parallel worker to use a unique database. ```yaml test: database: foo_test ``` ```yaml test: database: foo_test<%=ENV['TEST_ENV_NUMBER']%> ``` -------------------------------- ### Running Flatware on a Specific Directory (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md Specify a directory path after the `flatware` command and runner name to execute tests only within that directory. ```sh $ flatware rspec spec/features ``` -------------------------------- ### Running Both RSpec and Cucumber with Flatware (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md Execute both your RSpec and Cucumber test suites sequentially using Flatware for parallelization within each suite. ```sh $ flatware rspec && flatware cucumber ``` -------------------------------- ### Limiting Flatware Workers (Shell) Source: https://github.com/briandunn/flatware/blob/master/README.md Use the `-w` flag followed by a number to limit the maximum number of parallel workers Flatware will fork. ```sh $ flatware -w 3 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.