Controller Testing: Integration Tests
Explore how to perform integration testing in Ruby on Rails by verifying controller interactions with models and views. Understand configuring tests for user sessions and devise authentication, then write tests to check create actions and redirects.
Integration testing
Integration testing is done to check how various parts of the application interact. For example, creating a new link involves interaction between your controller and your model, and after successful creation, the controller has to render a view. If you want to check whether this interaction is successful, you can write an integration test for it.
Pre-test configuration
Before you can start writing your test, you must make some configurations keeping in mind the structure of your application.
Specifically, you must keep the following points in mind:
-
Your
Linkmodel is associated with yourUsermodel. Everylinkyou create in your fixtures must have auserattribute. -
All actions, other than
indexandshow, require an active user session to be accessed. This means ...