require 'database_cleaner' RSpec.configure do |config| config.before :suite do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with :truncation end config.before do DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction DatabaseCleaner.start end config.after do DatabaseCleaner.clean end end