Search code examples
ruby-on-railsspork

How to avoid Duplicate Entry DB errors that have appeared when I switched to Spork for testing


I just started using Spork and my tests are producing random "duplicate entry" errors from the DB. I assume this has something to do with a change in the way the DB is flushed between tests? How can I fix this?

These errors did not surface before Spork...


Solution

  • You could use something like Database Cleaner (https://github.com/bmabey/database_cleaner/)