Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@justin808
Created March 10, 2014 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justin808/9461052 to your computer and use it in GitHub Desktop.
Save justin808/9461052 to your computer and use it in GitHub Desktop.
Database Cleaner setup for Rails and Capybara
RSpec.configure do |config|
config.add_setting(:seed_tables)
config.seed_tables = %w(seed_table_1 seed_table_2)
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation, except: config.seed_tables)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation, {except: config.seed_tables}
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