Skip to content

Instantly share code, notes, and snippets.

@wejrowski
Created August 21, 2013 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wejrowski/6301586 to your computer and use it in GitHub Desktop.
Save wejrowski/6301586 to your computer and use it in GitHub Desktop.
Run all rails tests in isolation
require 'benchmark'
require 'socket'
ENV["RAILS_ENV"] = "test"
# Add test folder to load path
$: << './test'
puts Benchmark.measure{
# Assuming test_helper requires config/environment
require './test/test_helper'
}
Dir["#{Rails.root}/test/**/*_test.rb"].each do |file|
# Check AR connection. For some reason it disconnects after running tests
ActiveRecord::Base.verify_active_connections!
pid = fork do
require file
end
Process.wait(pid)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment