Skip to content

Instantly share code, notes, and snippets.

@godfat
Created October 18, 2011 10:00
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 godfat/1295078 to your computer and use it in GitHub Desktop.
Save godfat/1295078 to your computer and use it in GitHub Desktop.
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