Skip to content

Instantly share code, notes, and snippets.

@gists-app-test
Forked from davidrichards/spec_helper.rb
Created September 12, 2012 14:28
Show Gist options
  • Save gists-app-test/3706967 to your computer and use it in GitHub Desktop.
Save gists-app-test/3706967 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