Created
August 21, 2013 23:42
-
-
Save wejrowski/6301586 to your computer and use it in GitHub Desktop.
Run all rails tests in isolation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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