#49 ✓resolved
Chad Humphries

Mocha is broken out right on Ruby 1.9.1 in some cases

Reported by Chad Humphries | May 15th, 2009 @ 11:28 AM

In particular, I have several projects which use mocha, and do not use test/unit, rspec, or bacon. On ruby 1.9.1 they all explode because:

mocha/lib/mocha.rb:47:in remove_method': methodrun' not defined in Test::Unit::TestCase (NameError)

Comments and changes to this ticket

  • Chad Humphries

    Chad Humphries May 15th, 2009 @ 11:30 AM

    Let me also say before it comes up that I do not wish to install the test-unit gem in 1.9.1 if at all possible. It causes issues with some of the projects I'm prototyping at the moment.

  • James Mead

    James Mead May 16th, 2009 @ 05:07 PM

    Hmm. Thanks for letting me know. I'm looking into this now. Sorry I didn't see your ticket earlier. I think I need to sort out Lighthouse notifications. Cheers, James.

  • James Mead

    James Mead May 17th, 2009 @ 12:50 PM

    Hi Chad.

    One problem is that Mocha's acceptance tests are all based on aspects of Test::Unit which are not available in Ruby 1.9.1 - I've just had another go at trying to get them to run in Ruby 1.9.1 without any gems installed, but I think it's going to take me a while.

    In the meantime, I've tried writing a few tests using Mocha, but have been unable to reproduce your error. Do you have a simple test demonstrating this problem? Also can you tell me exactly what version of Ruby 1.9.1 you are using? I'm testing with ruby 1.9.1p0 (2009-01-30 revision 21907). I wonder whether something has changed since then.

    Also are your tests inheriting from Test::Unit::TestCase or MiniTest::Unit::TestCase? Both are available without gems installed, but the former is actually just a thin wrapper around the latter.

    One last thought, can you try requiring 'minitest/unit' before requiring 'mocha'? This should encourage Mocha to use the appropriate monkey-patching adapter.

    Cheers, James.

  • Chad Humphries

    Chad Humphries May 17th, 2009 @ 01:20 PM

    • Assigned user set to “James Mead”

    I'm on ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.7.0]. I'm using Micronaut, which does not descend from MiniUnit/Test, or Test::Unit. I use the RSpec style of hooking in Mocha via an adapter.

    Basically the issue from my end appears to be that it is trying to monkey patch something I'm not using or requiring. I can try requiring minitest/unit per your request and I'll you know what happens.

  • James Mead

    James Mead May 18th, 2009 @ 04:27 PM

    Hi Chad,

    Sorry not to get back to you sooner - I've been visiting my parents and have had long periods with no reliable internet connection. Even now I'm relying on wifi on a train!

    I've just committed a couple of changes [1] that will hopefully fix your problem.

    Are you in a position to checkout HEAD, build and install the gem locally? If you can, let me know if it works and I'll try and get a release out asap.

    Cheers, James.

    [1] http://github.com/floehopper/mocha/commit/213ce2187a84c25eeb7040238...

  • James Mead

    James Mead July 1st, 2009 @ 10:03 AM

    Hi Chad,

    There is now a release [1] incorporating the changes I mentioned above.

    It would be really helpful if you could tell me whether the newly released version 0.9.6 of the Mocha gem solves your problem.

    Thanks, James.

    [1] http://blog.floehopper.org/articles/2009/06/29/mocha-release-0-9-6

  • James Mead

    James Mead July 24th, 2009 @ 11:59 PM

    • State changed from “new” to “resolved”

    Believed fixed.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

A mocking & stubbing library for Ruby.

* <a href="http://github.com/floehopper/mocha">GitHub repository</a>
* <a href="http://mocha.rubyforge.org">Documentation</a>
* <a href="http://groups.google.com/group/mocha-developer">Mailing List</a>

People watching this ticket

Pages