All fake methods return self by default. It enables spying by default, but may lead to hard to debug errors.
For example when client is stubbed with:
stub(client).foo(1) { 'ABC' }
and then used:
client.foo(a).downcase
For a = 1 it will return the correct value, but for a = 2 it is going to fail with undefined method downcase for client. It has to fail in a friendlier way.
Fakes should return something like Bogus::DefaultReturnValue that would make clear, that the method was called on a wrong return value.
All fake methods return
self
by default. It enables spying by default, but may lead to hard to debug errors.For example when client is stubbed with:
and then used:
For
a = 1
it will return the correct value, but fora = 2
it is going to fail with undefined methoddowncase
forclient
. It has to fail in a friendlier way.Fakes should return something like
Bogus::DefaultReturnValue
that would make clear, that the method was called on a wrong return value.