Skip to content

Instantly share code, notes, and snippets.

@bloudermilk
Created July 25, 2013 23:07
Show Gist options
  • Save bloudermilk/6084619 to your computer and use it in GitHub Desktop.
Save bloudermilk/6084619 to your computer and use it in GitHub Desktop.
Example DatabaseCleaner config for fast tests
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.around(:each, type: :feature, javascript: true) do |example|
DatabaseCleaner.strategy = :truncation
example.run
DatabaseCleaner.strategy = :transaction
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