Search⌘ K
AI Features

Who Controls the Controllers?

Understand how controllers operate within Rails applications using test-driven development. Learn why traditional controller tests might be redundant, how business logic is separated, and methods to handle errors at the unit test level for more efficient testing.

All of the new tests pass, so let’s take stock of what we have so far. We still have one test pending: our end-to-end test still doesn’t like that the create action can’t be found in the ProjectsController. Now we have all the pieces we need to write that action.

Controller testing as low value

The next question is, are we going to write any tests specifically to target the controller’s logic? The answer, perhaps surprisingly, is no. Or at least not with the tools already discussed.

Controller tests, which have been a feature of Rails initially, have increasingly been seen as lower-value tests in a couple of different ways.

If we ...