[mocha-developer] stubs! method
jay at jayfields.com
Mon Jan 21 13:42:33 EST 2008
Hello James et al.
I try to set only one expectation per test, but I also dislike having
extra stub declarations that are no longer used, thus I often find
myself wanting Object.expects(:foo).at_least_once. That works, but I
don't actually "expect" foo to be called, in fact, I don't care, I
only want to know when it isn't called so I can remember to clean up
the test. Since I don't "expect" foo, it's also quite verbose for my
Given the above, I'd really like a .stubs! method. The .stubs! method
would convey that this is a stub and is unimportant for the test;
however, if you don't call the method at least once, it will remind
you to remove the stub.
I also think that stubs! is appropriate given that the intended use
of ! methods is "the dangerous version of a method". I'd say a stub
that raises an exception if it's never called is definitely the
dangerous version of the method.
More information about the mocha-developer