Skip to content

Instantly share code, notes, and snippets.

@adam12
Forked from jsteiner/database_cleaner.rb
Created January 9, 2020 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam12/28c25476c73d34f010157c78cc16695e to your computer and use it in GitHub Desktop.
Save adam12/28c25476c73d34f010157c78cc16695e to your computer and use it in GitHub Desktop.
Database Cleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :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