Testing is helpful for ensuring that your code runs (driver code). This is to make sure that current features work, old features still work, and future work will be easily tested. By default, every Rails application has three environments: development, test, and production.
Rails offers three kinds of testing:
- Unit tests: In the context of Rails, unit tests are meant primarily to cover the domain logic in your models, which include things like validations, calculations, search methods, and any other interesting functionality that your models implement.
- Functional tests: These provide a way to verify that the actions for a single controller are working as expected, and allow you to do things such as post data to a specific action and verify the correct response is returned
- Integration tests: Any given session with a Rails application will span across several models and controllers. Integration tests provide a way to test those kinds of interactions. Essentia