You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Final line should be true. Literally all aspects of the two objects are identical, including the internal SimpleDelegator delegate object! Failing to provide adequate comparison makes the class untestable.
Indeed, in rspec testing, I get unhelpful failures like:
You can compare a SimpleDelegate object to an identical object of the class it wraps, and everything is OK. But if you compare it to another SimpleDelegate-wrapped object, now you depend on the interior object’s willingness to declare itself == to the wrapped object. Worse, == ignores the attributes we have set at the IoDecorator level, since the internal object doesn't know about them.
BUT, this breaks comparison to the raw delegate (e.g. File objects like file don't support .original_name). So anything useful we do in our subclass is a problem. Equality can be tested against objects either:
of (or descending from) the wrapped class, or
fitting the profile of the subclass (IoDecorator),
BUT NOT BOTH.
SimpleDelegate chooses the former. This pattern breaks OO completely and should be universally discouraged.
Final line should be
true
. Literally all aspects of the two objects are identical, including the internal SimpleDelegator delegate object! Failing to provide adequate comparison makes the class untestable.Indeed, in rspec testing, I get unhelpful failures like:
Literally, "I got exactly what I expected, there is no discernable difference, but I failed anyway."
Note that this seems to be a limitation of SimpleDelegator with IO objects that is not part of the objects themselves:
That makes it a particularly questionable choice for
Hydra::Derivatives::IoDecorator
, since all it does is wrap IO.The text was updated successfully, but these errors were encountered: