Fixtures

Rails has always made it easy to manage a database just for test data, which is automatically cleared between tests. (While there’s no denying this is tremendously useful, it has also lulled all of us into feeling that a test that touches the database—a huge third-party dependency—is somehow a unit test.) One of the most valuable ways in which Ruby on Rails has supported automated testing is through the use of easily created data that is accessible to all the tests in your system, no matter when or where you write those tests, using fixtures specified in a YAML file. (YAML is a file format. The acronym stands for YAML Ain’t Markup Language.[16]) It’s sometimes hard for an experienced Rails programmer to remember just how exciting the ...

Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.