Disable all observers in your test suite by default. They should not be complicating your model tests because they should have separate concerns anyway. You don't need to unit test that observers actually fire, because ActiveRecord's test suite does that, and your integration tests will cover it.
2 Matching Annotations
- Sep 2024
-
stackoverflow.com stackoverflow.com
-
-
Rails' observers were partly inspired by aspect-oriented programming -- they're about cross-cutting concerns. If you're putting business logic in observers that is tightly coupled to the models they're observing, you're doing it wrong IMO.
Tags
- testing: avoid over-testing: don't test the same thing in many different tests
- software development: code organization: where does this code belong?
- testing: only test the thing you're trying to test
- separation of concerns
- tightly coupled
- observer pattern
- good policy/practice/procedure
- aspect-oriented programming
Annotators
URL
-