[mocha-developer] Problem with RSpec and Mocha/Stubba
jamesmead44 at gmail.com
Wed Sep 13 08:23:46 EDT 2006
On 13/09/06, Luke Redpath <contact at lukeredpath.co.uk> wrote:
> I've recently upgraded to the latest versions of Mocha and RSpec (0.3.2and
> 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
> 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
> 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:
> I've x-posted this to the Mocha dev list and RSpec dev list as I'm not
> sure where the issue lies.
Chris Roos & I have just taken a look at your problem. It seems that
Stubba::SetupAndTeardown#setup_stubs and #teardown_stubs are not getting
called. You are right about the missing require 'test/unit' in
I don't think this area of Mocha has changed much recently, but I could be
wrong. If you only need stubs and no mocks, you could get away with this
# add this line to your context's setup
$stubba = Stubba::Central.new
Getting the auto-verify to work and sorting this out properly needs a bit
Hope that helps.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mocha-developer