My legacy code is using DatabaseCleaner which wipes out database after each test being done. However it also wipes out loaded fixtures data and causes some tests which are using fixtures to fail, something like:
ActiveRecord::RecordNotFound Exception: Couldn't find Country with 'id'=593363170
To make them work together, how can I rewrite all fixtures back to database during test? (I mean not rake tasks)
Solution:
Set
self.use_transactional_fixtures = falseat the beginning of the file before which you want to reload fixtures.Or use
use_transactional_testsin Rails 5.Do not set it in
spec_helperas it applies globally so conflicts with DatabaseCleaner.