Skip to content

Instantly share code, notes, and snippets.

@davidrichards
Created September 12, 2012 14:10
Show Gist options
  • Save davidrichards/3706854 to your computer and use it in GitHub Desktop.
Save davidrichards/3706854 to your computer and use it in GitHub Desktop.
module SpecHelpers
def setup_memory_db
databases_config = YAML.load_file(File.expand_path('../../config/database.yml', __FILE__))
connection = ActiveRecord::Base.establish_connection(databases_config['memory'])
load File.expand_path('../../db/schema.rb', __FILE__)
DatabaseCleaner[:active_record, :connection => connection]
DatabaseCleaner.strategy = :deletion
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.start
end
def teardown_memory_db
DatabaseCleaner.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment