psyho / bogus

Fake library for Ruby
Other
359 stars 14 forks source link

Fakes shouldn't return themselves by default #15

Closed wrozka closed 11 years ago

wrozka commented 11 years ago

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.