Testing Null Objects
Posted on
A Null Object is a drop in replacement for one of the other objects in your
system that provides sensible defaults when the other object is unavailable.
For example, I recently wrote about
returning the path to a blank partial as a sensible default for to_partial_path
.
Null Objects remove respond_to?
and nil?
checks,
and make code cleaner and easier to understand. It almost seems like there's
no downside. Almost.
Read this post in full on the thoughtbot blog: https://robots.thoughtbot.com/testing-null-objects