What You’ve Done

You’ve learned a lot about model testing—about the services Rails provides for testing models, and fixtures and factories as mechanisms for creating consistent test data. With this chapter you’ve started to transition from testing models to testing the user-facing parts of the application. Mock testing is useful for testing models, but it becomes especially useful when trying to shield the various layers of your application from each other.

In the next section you’ll learn about testing the controller and view layers. Mock objects can be an important part of controller testing; creating mock models allows the controller tests to proceed independently of the model test.

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.