Skip to content

Instantly share code, notes, and snippets.

@godfat godfat/bin-spork.rb
Created Oct 18, 2011

Embed
What would you like to do?
Run Spork without affecting `rake test`
#!/usr/bin/env ruby
$LOAD_PATH.unshift('./lib').unshift('./test')
require 'spork'
# monkey patch...
class Spork::Server
def run_with str
eval(str)
end
end
load Gem.bin_path('spork', 'spork')
#!/usr/bin/env ruby
require 'drb'
# this allows Ruby to do some magical stuff so you can pass an output stream over DRb.
DRb.start_service("druby://127.0.0.1:0")
obj = DRbObject.new_with_uri("druby://127.0.0.1:8988")
obj.run_with <<-RUBY
require './config/application'
::Rails.application.require_environment!
RUBY
obj.run_with <<-RUBY
# This code will be run each time you run your specs.
loadup = lambda{ |glob|
Dir[glob].each{ |f| load f }
}
loadup['app/**/*.rb']
loadup['lib/**/*.rb']
RUBY
obj.run(Dir['test/**/*_test.rb'], $stderr, $stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.