Iteration C4: Functional Testing of Controllers

Now for the moment of truth. Before we focus on writing new tests, we need to determine if we’ve broken anything. Remembering our experience after we added validation logic to our model, with some trepidation we run our tests again:

 depot>​​ ​​bin/rails​​ ​​test

This time, all is well. We added a lot, but we didn’t break anything. That’s a relief, but our work isn’t done yet; we still need tests for what we just added.

The unit testing of models that we did previously seemed straightforward enough. We called a method and compared what it returned against what we expected it to return. But now we’re dealing with a server that processes requests and a user viewing responses in a browser. What ...

Get Agile Web Development with Rails 5, 1st Edition 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.