I had a question about @georgebrock’s excellent article about testing null objects. I have a null object that’s a stand-in for Address, which is an ActiveRecord
model. There are a lot of methods on Address that are things I would never expect to call in a view, such as #autosave_associated_records_for_addressable
. It seems like adding methods to my NullAddress
here just to make the matcher work is overkill.
I’ve tried filtering out methods from ActveRecord::Base.instance_methods
, but there are still a number of dynamically generated methods that clutter the list of methods in the public interface of Address
. How do folks handle this? I would really like to be able to cleanly track the public interface of my models and null objects together, but it seems difficult to figure out a sensible list that doesn’t require creating a bunch of useless, crufty methods on my null object.