Skip to content

Instantly share code, notes, and snippets.

@carloslopes
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carloslopes/9135866 to your computer and use it in GitHub Desktop.
Save carloslopes/9135866 to your computer and use it in GitHub Desktop.
DatabaseCleaner configuration
RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
config.before :suite do
DatabaseCleaner.clean_with :truncation
end
config.before :each do
if example.metadata[:js] || example.metadata[:deletion]
DatabaseCleaner.strategy = :deletion
else
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.start
end
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