Skip to content

Instantly share code, notes, and snippets.

@toctan
Last active December 25, 2015 01:39
Show Gist options
  • Select an option

  • Save toctan/6896156 to your computer and use it in GitHub Desktop.

Select an option

Save toctan/6896156 to your computer and use it in GitHub Desktop.
database_cleaner with RSpec
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 => 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