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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.