Skip to content

Instantly share code, notes, and snippets.

@warp
Created January 21, 2015 20:41
Show Gist options
  • Save warp/84b4f5295d93da115698 to your computer and use it in GitHub Desktop.
Save warp/84b4f5295d93da115698 to your computer and use it in GitHub Desktop.
database cleaner
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, :js) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each, :truncate) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.append_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