Created
January 21, 2013 21:00
-
-
Save supernullset/4589331 to your computer and use it in GitHub Desktop.
Multi-Database DatabaseCleaner setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very helpful, thanks for sharing!