0.03
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Parallel spec runner for RSpec 3
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 11.3
~> 3.3.4
~> 3.5.0
~> 0.45.0
~> 0.12.0
~> 0.9.5

Runtime

 Project Readme

RSpec::Parallel

wercker status

Parallel spec runner for RSpec 3.

Install

$ gem install parallel-rspec

Getting Started / Usage

Parallel-rspec bundles parallel-rspec binary which can be used directly:

$ parallel-rspec spec

If spec/parallel_spec_helper.rb is found, the parallel-rspec command loads it before starting the test. Since parallel-rspec uses fork(2) to spawn off workers, you must ensure each worker runs in an isolated environment. Use the after_fork hook to reset any global state.

RSpec::Parallel.configure do |config|
  config.after_fork do |worker|
    # Use separate database.
    ActiveRecord::Base.configurations["test"]["database"] << worker.number.to_s
    ActiveRecord::Base.establish_connection(:test)
  end
end

In this case, your workers assume sequence of databases exist and has right schema already. Rspec-parallel ships with db:test:prepare_sequential rake task to prepare them for your Rails application:

$ rake db:test:prepare_sequential

Controll concurrency

The number of workers spawned by parallel-rspec is the number of available CPU cores by default. To controll the concurrency, use concurrency configuration option:

RSpec::Parallel.configure do |config|
  config.concurrency = 4
end

db:test:prepare_sequential task takes concurrency as an argument.

$ rake "db:test:prepare_sequential[4]"

License

MIT © Yuku TAKAHASHI