[mocha-developer] Problem with RSpec and Mocha/Stubba

Luke Redpath contact at lukeredpath.co.uk
Wed Sep 13 07:53:42 EDT 2006


I've recently upgraded to the latest versions of Mocha and RSpec  
(0.3.2 and 0.6.3 respectively) and I'm no longer able to use Mocha/ 
Stubba with RSpec. Its actually only Stubba I'm interested in as I  
use RSpec's built-in mocking library.

I require stubba in my spec file but whenever I try and run my spec  
it fails with the error:

Unintialized constant Test

Digging around the Mocha source, it seems that it is trying to add  
extensions to Test::Unit which I haven't required as I don't need it.

This isn't a Rails project, just a standalone Ruby lib that I'm  
working on.

I've tried the obvious solution of requiring test/unit but that has  
its own issues (i.e. it puts test::unit output at the bottom of my  
spec output) and it still doesn't work, I get a new error:

Undefined method 'stub' for nil:NilClass

Here's the line where I'm trying to stub a method on an existing  
instance of an object:

@connection.stubs(:logged_in?).returns(true)

I've x-posted this to the Mocha dev list and RSpec dev list as I'm  
not sure where the issue lies.

Cheers,
Luke Redpath
contact at lukeredpath.co.uk



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20060913/79b9a3f8/attachment-0001.html 


More information about the mocha-developer mailing list