Created
October 11, 2011 21:16
-
-
Save jesscanady/1279474 to your computer and use it in GitHub Desktop.
Running "rake" doesn't clobber your testing db anymore!
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
# Rails.root/lib/tasks/test.rake | |
Rake.application.remove_task 'db:test:prepare' | |
namespace :db do | |
namespace :test do | |
task :set_env do | |
end | |
task :prepare => [:set_env, :environment] do |t| | |
# this would normally drop the entire DB. | |
# Let's make sure we're connected to the test db and then only truncate the tables we want. | |
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) | |
Form.delete_all | |
Question.delete_all | |
Option.delete_all | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment