Rails Controller Testing

screenshot of Rails Controller Testing

Brings back `assigns` and `assert_template` to your Rails tests

Overview

The Rails::Controller::Testing gem is a helpful tool for controller testing in Rails applications. It brings back the "assigns" method and the "assert_template" method, which were removed in Rails 5. The gem allows you to easily access and test instance variables passed to views.

Features

  • Brings back assigns: The gem restores the "assigns" method, which allows you to access instance variables passed to your views in controller tests.
  • Restores assert_template: The gem also restores the "assert_template" method, which enables you to assert that particular templates have been rendered in your controller and integration tests.

Summary

The Rails::Controller::Testing gem brings back useful methods for controller testing in Rails applications. It restores the "assigns" method, allowing you to access instance variables passed to views, and the "assert_template" method, enabling you to assert that specific templates have been rendered. Installation is straightforward, and the gem integrates well with RSpec.