Model Testing Strategies
Explore testing strategies for Rails models by understanding where to place tests for database constraints, how to validate complex callbacks, and why using Factory Bot improves test reliability. This lesson helps you create maintainable and accurate model tests that support sustainable app development.
We'll cover the following...
We'll cover the following...
Models tend to be inputs to (and outputs of) our business logic. In many cases, models are only bags of data, so they don’t require that much testing themselves. That said, there are three considerations related to model testing:
- Tests for database constraints, like we wrote in Writing Tests for Database Constraints in the previous lessons of this