Skip to content

Instantly share code, notes, and snippets.

@supernullset
Created January 21, 2013 21:00
Show Gist options
  • Save supernullset/4589331 to your computer and use it in GitHub Desktop.
Save supernullset/4589331 to your computer and use it in GitHub Desktop.
Multi-Database DatabaseCleaner setup
RSpec.configure do |config|
config.before :suite do
# set up a global cleaning strategy
DatabaseCleaner.clean_with(:truncation)
# AR specific strategy
DatabaseCleaner[:active_record].strategy = :truncation
# Explicitly tell DatabaseCleaner what connection is AR
DatabaseCleaner[:active_record, connection: :pediafed_test]
# Mongoid specific strategy
DatabaseCleaner[:mongoid].strategy = :truncation
# Explicitly tell DatabaseCleaner what connection is MongoDB
DatabaseCleaner[:mongoid, connection: :pediafed_test]
end
config.before :each do
DatabaseCleaner.start
end
config.after :each do
DatabaseCleaner.clean
end
end
@phlipper
Copy link

Very helpful, thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment