Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created April 28, 2011 06:38
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 aaronjensen/945912 to your computer and use it in GitHub Desktop.
Save aaronjensen/945912 to your computer and use it in GitHub Desktop.
run rspec in a fork off rake to prevent loading the rails environment again
# /lib/tasks/rspec.rake
namespace :fork do
task :spec do
fork do
RSpec::Core::Runner.disable_autorun!
RSpec::Core::Runner.run(['spec'], $stderr, $stdout) ? exit(0) : exit(1)
end
Process.wait
raise 'rspec failed' unless $?.exitstatus == 0
# exiting the fork can cause MySql to drop the connection
# but AR doesn't notice. This mitigates.
ActiveRecord::Base.connection.reconnect! if ActiveRecord::Base.connected?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment