Skip to content

Instantly share code, notes, and snippets.

@isuke
Last active January 2, 2018 09:02
Show Gist options
  • Save isuke/11d050d93759fa6eb4b6 to your computer and use it in GitHub Desktop.
Save isuke/11d050d93759fa6eb4b6 to your computer and use it in GitHub Desktop.
The best of database_cleaner setting
RSpec.configure do |config|
# Use transactions by default
config.before :each do
DatabaseRewinder.strategy = :transaction
end
# Switch to truncation for javascript tests, but *only clean used tables*
config.before :each, js: true do
DatabaseRewinder.strategy = :truncation, {pre_count: true}
end
config.before :each do
DatabaseRewinder.start
end
config.after :each do
DatabaseRewinder.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment