Controller Testing: Functional Tests
Learn about functional testing in Rails and test your controller actions.
We'll cover the following
You already know that your controllers are responsible for handling incoming web requests to the application. They respond to these requests by rendering views or interacting with the models.
Functional testing
In functional testing of your controllers, you want to check how the actions in your controller handle the various web requests and whether the expected response is received.
In your functional tests, you want to check things such as:
- Whether the web request was successful
- Whether the user was redirected to the right page
- Whether the appropriate message was displayed to the user in the view
To test your LinksController
, you will need to go into the test/controllers/links_controller_test.rb
file. Since we used scaffolding for the project, this file is already populated with a number of tests.
You will need to go over a portion of this file to understand what is going on.
Testing the index action
Get hands-on with 1400+ tech skills courses.