Controller Testing: Functional Tests
Explore how to write and run functional tests for Ruby on Rails controllers to check if actions handle web requests correctly. Understand testing GET requests for index and show actions, verifying responses, redirects, and messages. This lesson helps you ensure your controller actions perform as expected by using fixtures and Rails test commands.
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 ...