tent/tentd — pull request #46 by amcinnes (2012-11-16 09:00:57+00:00)
Title: Clean the database between tests using database_cleaner

When I first checked out tentd, I ran the tests (locally, on my own computer) and a couple of them failed. (issue #45, #21.) I found that these failures were triggered by stuff that was left in the database by previous tests.

The order in which `rake` runs the tests depends on the order of files in the spec directory and its subdirectories, which can be different from one machine to the next. The specific failures was seeing didn't happen on Travis because on Travis the files are consistently run in an order that works.

Tests are more useful for reproducing and diagnosing problems when they're deterministic and independent of each other. So I've set up database_cleaner. It ensures each test starts with a clean database, by running each test within a database transaction and rolling back the transaction afterwards.