Module 14 Β· Testing the API β Lesson 2 of 5 Β· ~14 min
Fixtures: Your Test World
Fixtures: a fresh, known world for every test
Every test you've watched pass so far reads users(:demo), bookings(:upcoming), walkers(:luna) β plain-looking method calls that hand back real, saved ActiveRecord objects. Where do those rows come from? Fixtures: YAML files under test/fixtures/, one file per model, each entry a named row. test_helper.rb's fixtures :all loads every one of them fresh before each test runs, so no test ever depends on data left behind by a previous test β every test starts from the exact same known world.