Skip to content

Instantly share code, notes, and snippets.

@jesscanady
Created October 11, 2011 21:16
Show Gist options
  • Save jesscanady/1279474 to your computer and use it in GitHub Desktop.
Save jesscanady/1279474 to your computer and use it in GitHub Desktop.
Running "rake" doesn't clobber your testing db anymore!
# 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