public
Created

Database Cleaner

  • Download Gist
database_cleaner.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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

Where in your project do you typically put this file and from where is it required (test_helper.rb)?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.