[mocha-developer] Object.stubs doesn't seem to work.

Jonathan Stott jonathan.stott at gmail.com
Mon Jul 30 10:15:47 EDT 2007


I'm using Mocha 0.5.3 and I want to stub out a call to Time.now, just
like the example in the post

However, trying it in irb gets me the following error:

>> require 'mocha'
=> true
>> Time.stubs(:now).returns(Time.parse('Thu Feb 01 00:00:00 UTC 2007'))
NoMethodError: undefined method `stub' for nil:NilClass
        from /usr/lib/ruby/gems/1.8/gems/mocha-0.5.3/lib/mocha/object.rb:57:in
        from (irb):2

Has this way of stubbing been depreciated between 0.5.0 and 0.5.3, and
if so, what is the new way of stubbing for an Object.method ?


More information about the mocha-developer mailing list