Skip to content

Instantly share code, notes, and snippets.

@jurgens
Created November 22, 2013 10:07
Show Gist options
  • Save jurgens/7597643 to your computer and use it in GitHub Desktop.
Save jurgens/7597643 to your computer and use it in GitHub Desktop.
rspec/support/database_cleaner.rb
require 'database_cleaner'
RSpec.configure do |config|
config.before(:each) do |example_group|
DatabaseCleaner.strategy = if (Capybara.current_driver != :rack_test)
[:truncation, { except: %w[statuses] }]
else
: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