This is the 17th video in the Getting Started with Rails 7 series. In this video Mike refactors the existing tests to move shared tests between models to a helper module that both test classes include. In addition, he creates a method to test that all fixtures are valid for each model. After that, he moves some of the repeated controller assertions into private methods.
This video covers:
- 00:00:10 Introduction and review
- 00:02:17 Add method to test_helper that checks validity of fixtures for a given model
- 00:08:16 Create, require, and include shared test support module for Visible concern behavior
- 00:12:39 Start moving status setup code to VisibleTestHelpers module
- 00:14:57 Move shared tests to included block in helper module
- 00:18:23 Refactor test model object creation into private methods
- 00:24:33 Make shared tests in helper module general enough to work for both models
- 00:30:58 Refactor out repeated assertions in ArticlesControllerTest
- 00:34:32 Review, commit, and push code
The code for this series is open source and available on GitHub. View the commit for this video here.