...

/

Simulating Requests

Simulating Requests

Learn about requests test performance, goals, and simulating requests in requests test.

We'll cover the following...

Ideally, our controllers are relatively simple. The complicated functionality is in a model or other object and tested in our unit tests for those objects. One reason this is a best practice is that models are easier to test than requests because they’re easier to extract and are used independently in a test framework.

Note: A request test should test the behavior of a single request. A request test should not fail because of problems in the model.

Request tests performance

A request test that overlaps with model behavior is part of the awkward middle ground of testing that the Rails 5 changes are designed to avoid. If the request test is going to the database, the test is slower than it needs to be. If a model failure can cascade into the controller tests, it’s harder than it ...