Skip to content

Instantly share code, notes, and snippets.

@jphenow
Created October 6, 2014 22:42
Show Gist options
  • Save jphenow/2639ae1205b8d3ea154a to your computer and use it in GitHub Desktop.
Save jphenow/2639ae1205b8d3ea154a to your computer and use it in GitHub Desktop.
forked Rspec
require 'rspec/core/rake_task'
@parallel_limit = 4
files = Dir.glob("spec/**/*_spec.rb")
pids = []
@parallel_limit.times do |i|
pids << fork do
# Run the tests
opts = files.each_slice(files.count / @parallel_limit).to_a[i].join(",")
puts "Fork #{i} testing #{opts}"
RSpec::Core::RakeTask.new("spec#{i}") do |t|
t.pattern = opts
end
Rake::Task["spec#{i}"].execute
# Force the fork to end without running at_exit bindings
Kernel.exit!
end
end
Process.waitall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment