Skip to content

Instantly share code, notes, and snippets.

@JobV
Forked from JanDintel/db_cleaner.rb
Created November 4, 2013 09:48
Show Gist options
  • Save JobV/7300358 to your computer and use it in GitHub Desktop.
Save JobV/7300358 to your computer and use it in GitHub Desktop.
# spec/support/db_cleaner.rb
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
if example.metadata[:feature]
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
end
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