[mocha-developer] Undefined method stub

James Mead jamesmead44 at gmail.com
Wed Aug 29 09:51:35 EDT 2007

On 29/08/2007, Felix E. Klee <felix.klee at inka.de> wrote:
> This works, but if a test framework is necessary, then Mocha seems to be
> uninteresting for me: I want to use it when demoing a Ruby on Rails
> application, i.e. in a development environment, or maybe - during the
> alpha phase - in a production environment.
> Should I better forge my own Time.now function?

This isn't really what Mocha was intended for - it's really intended for
doing "interation-based testing" [1]. The main technical reason you need to
use it within a test is that it hooks into the point at which each test ends
to put any class it has modified back into its original state.

You could look at Mocha::TestCaseAdapter class and write your own
equivalent, but if the only thing you need it for is stubbing Time.now - I'd
recommend you create your own fake version of Time.now.

I hope that helps.

1. http://www.martinfowler.com/articles/mocksArentStubs.html

More information about the mocha-developer mailing list