mattbrictson / bundle_update_interactive

A stylish interactive mode for Bundler, inspired by `yarn upgrade-interactive`
MIT License
137 stars 3 forks source link

Refactor `OutdatedGem`; install FactoryBot for improved test coverage #5

Closed mattbrictson closed 2 months ago

mattbrictson commented 2 months ago

The core model class of this project is OutdatedGem. Currently, an instance of this class represents a complex object graph that is tightly coupled with Bundler classes like Bundler::LazySpecification. Because of this complexity and broad scope, writing test coverage for different scenarios involving OutdatedGem is prohibitively difficult without a significant amount of mocking or fixture setup.

This PR addresses this problem by refactoring OutdatedGem to be a shallow, struct-like data class that no longer has external Bundler dependencies.

With that refactor in place, I was able to install FactoryBot and use it to easily write some new unit tests for CLI::Row.