Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jhollinger
Created December 21, 2012 05:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jhollinger/4350949 to your computer and use it in GitHub Desktop.
Save jhollinger/4350949 to your computer and use it in GitHub Desktop.
Optimal RSpec Database Cleaner config
Capybara.javascript_driver = :webkit # Selenium works, but not as well
RSpec.configure do |config|
config.use_transactional_fixtures = false
# Use transactions by default
config.before :each do
DatabaseCleaner.strategy = :transaction
end
# For the javascript-enabled tests, switch to truncation, but *only on tables that were used*
config.before :each, :js => true do
DatabaseCleaner.strategy = :truncation, {:pre_count => true}
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