Parallel RSpec runner based on multi-processes
Ruby
Latest commit e8ab5e1 Jan 14, 2017 @yuku-t Enhance delivery log
Permalink
Failed to load latest commit information.
bin
lib
spec
.gitignore
.rspec Initialize rspec Dec 18, 2016
.rubocop.yml Rename the project as parallel-rspec Dec 31, 2016
.simplecov Setup simplecov Dec 18, 2016
.yardopts
CHANGELOG.md Add CHANGELOG.md Jan 7, 2017
Gemfile
LICENSE
README.md Rename the project as parallel-rspec Dec 31, 2016
Rakefile
parallel-rspec.gemspec Rename the project as parallel-rspec Dec 31, 2016
wercker.yml Add wercker.yml Dec 23, 2016

README.md

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