Created
June 27, 2013 15:21
-
-
Save fabioyamate/5877369 to your computer and use it in GitHub Desktop.
Faster Rails test runs...with Unix! http://www.jstorimer.com/blogs/workingwithcode/8136295-screencast-faster-rails-test-runs-with-unix
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
#!/usr/bin/env ruby | |
require 'socket' | |
test_file = ARGV[0] | |
socket = UNIXSocket.new('testing.sock') | |
socket.write(test_file) | |
socket.close_write | |
puts socket.read |
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
#!/usr/bin/env ruby | |
$: << '.' | |
$: << './spec' | |
puts $LOAD_PATH | |
require 'socket' | |
require 'benchmark' | |
ENV['RAILS_ENV'] = 'test' | |
rails_boot = Benchmark.measure { | |
require './config/application' | |
} | |
puts "Rails loaded after #{rails_boot}" | |
server = UNIXServer.new('testing.sock') | |
parent_process_pid = Process.pid | |
at_exit { | |
if Process.pid == parent_process_pid | |
File.unlink('testing.sock') | |
end | |
} | |
trap('INT') { exit } | |
loop do | |
client = server.accept | |
test_file = client.read | |
pid = fork do | |
STDOUT.reopen(client) | |
require test_file | |
end | |
Process.wait(pid) | |
end |
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
Launch tserver on the Rails project | |
./tserver | |
Then run a spec | |
./tclient spec/models/my_model.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment