ankane/multiverse

Proper Way to Clean Up Database After rake test

Closed this issue · 2 comments

Hi, what is the proper way to clean up the databases after running unit test? Right now only the main database is cleaned up after test.

Hey @edmondchui, what do you use to clean the main database? If it's Database Cleaner, instructions are in the readme. If it's something else, I'm not sure.

I don't use anything to clean the main database. I think out of the box rake test use transaction to rollback changes made with each test.

I figure out I can use nested transaction to achieve cleaning up multiple databases, as suggested here: http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html

def test_multiverse
  SecondDatabase::Base.transaction do
    ...
  end
end