Skip to content

Instantly share code, notes, and snippets.

@reinh
Forked from coreyhaines/.rspec
Last active December 15, 2015 00:19
Show Gist options
  • Save reinh/5172435 to your computer and use it in GitHub Desktop.
Save reinh/5172435 to your computer and use it in GitHub Desktop.
require 'active_record'
require 'database_cleaner'
connection_info = YAML.load(File.open("config/database.yml"))["test"]
ActiveRecord::Base.establish_connection(connection_info)
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment