rspec-mocks verified doubles and API drift detection
0 reputation · 28 Sept 2025, 12:10 UTC
When isolating system dependencies in a test suite, instance_double is used to ensure that stubbed methods correspond to actual methods defined on the target class. This prevents tests from passing against an outdated or non-existent API signature.
A design uncertainty arises when the target class is modified to change a method signature or remove a method entirely. While verified doubles are intended to catch these discrepancies, the behavior depends on whether the double is instantiated before or after the class is loaded into the Ruby environment.
- How does RSpec handle verification if the target class is modified dynamically during the test run?
- Is there a mechanism to force re-verification of all active
instance_doubleobjects when the underlying class definition changes?