Functional Testing of Controllers
Explore how to conduct functional tests on Rails controllers to verify the integration of models, views, and controllers. Understand how to use assertions like assert_select to check HTML elements, layout, and data formatting. This lesson helps you ensure your catalog display works correctly and maintains stability through iterative development.
We'll cover the following...
Now for the moment of truth. Before we focus on writing new tests, we need to determine if we’ve broken anything. Remember our experience after we added validation logic to our model! With that in mind, let’s run our tests again:
depot> bin/rails test
Note: We have provided a live terminal at the end of this lesson. You can run the commands of this lesson in the provided terminal.
This time, all is well. We added a lot, but we didn’t break anything. That’s a relief! Our work isn’t done yet, though. We still need tests for what we just added.
The unit testing of models that we did previously seemed straightforward. We called a method and compared what it returned against what we expected it to return. However, we are now dealing with a server that processes requests and a user viewing responses in a browser. ...