Summary

Summarize what we’ve covered in this chapter.

Factories vs. fixtures

In this chapter, we saw how Rails provides fixtures as a straightforward way to create a set of test data shared across multiple tests. However, fixtures are so simple that they tend not to be adaptable to more complex product needs. Factory tools, which take a little more initial setup, allow for more flexibility at some test performance costs. The two structures are not mutually exclusive. One pattern for combining them is to create a complex scenario in fixtures for use in integration or complex controller tests and to use factories for unit tests or simpler controller tests.

Get hands-on with 1400+ tech skills courses.