Open bannable opened 2 years ago
It seems that this:
def foo
bar
end
can be removed, and the error still reproduces.
Adding an expected result solves this, such as:
instance_spy('Injected', bar: true)
So I think this is an artefact from the forward, as instance doubles only verify methods which are stubbed, where as the spy mode calls as_null_object
where everything returns self, so is more like a method missing call, I think forward is complaining about that
By looking at the implementation, it doesn't look like Forwardable
's warning is fair ([1], [2]). I'm not certain if it's Forwardable
or instance_spy
to blame.
I guess that spy is accepting and records every method call with method_missing
. But does it define respond_to_missing?
to declare that it does so? Is this sufficient for Forwardable
to work and skip this warning?
Are you interested in getting to the bottom of this?
I'd start with an attempt to reproduce the warning with a class defining dynamic methods used as a delegator target.
Our doubles respond_to?
true for this case, it seems Forwardable
checks theres an actual method with this warning, we don't define that unless you specifically mock out the method, I don't think we want to change that behaviour, and given there is an easy alternative, I'm inclined to close this as a "not something we can fix"
Subject of the issue
When using Forwardable delegators, if the destination object is a spy, a kernel warning will be emitted of the form:
Your environment
Steps to reproduce
Expected behavior
Both examples will pass.
Actual behavior
fowardable behavior with a null object (spy) is expected not to output to stderr
fails.