Mocha Release 0.9.6
Posted by James Mead Mon, 29 Jun 2009 16:29:54 GMT
Release Notes
- Version 2.0.1 of the test-unit gem introduced a private
run_testmethod onTestCasewhich clashed with the publicTestRunner#run_testmethod. So this latter method has been renamed torun_as_test. - Stop requiring
rubygems– this should be an environmental choice for the user. This describes why requiringrubygemsin your library code is a bad idea. - It seems like overkill to vendorize
coderayandmeta_projectwhen they’re only needed to generate the examples for documentation and for publishing files on RubyForge. So I’m removing them and installing them locally as gems when I need them. - Added support for test-unit gem (version >= 2.0). Note that as with other versions of Test::Unit I’m completely replacing the
TestCase#runmethod. Unfortunately in version 2.0.0 this method differs slightly from the same method in version 2.0.1 & 2.0.2, so we have to provide different implementations to ensure that the internal working of Test::Unit are not compromised by Mocha. Note also that unless the test-unit gem is loaded, requiring'test/unit'leads to a mixture of standard library and gem classes being loaded causing errors. To avoid a dependency onrubygems, the gem is loaded only ifMOCHA_OPTIONSis set touse_test_unit_gem– this option is only intended for use in running Mocha’s own tests. It might be worthwhile to create a shim gem likeminitest_tu_shimto allow the test-unit gem to completely replace the standard library, but that’s a job for another day. My previous article on Test::Unit and MiniTest explains how theminitest-tu-shimworks. The changes in theRakefileare to make the default task run with the test-unit gem (version >= 2.0). - Renamed
Mocha::Standaloneto Mocha::API to better reflect its purpose. Added a deprecation warning for those who are referencingMocha::Standalone. - Fix exception raised by HasEntry#matches? when first parameter is not a
Hash(thanks to Taylor Barstow). - Ken Collins reported that Mocha is always loading MiniTest if it is available and loading it causes some
Rails/ActionPacktests to break. I’ve removed the loading of MiniTest, but this now means the user has to ensure that if they want to use MiniTest in conjunction with Mocha, he must load MiniTest before loading Mocha. - Implemented Bacon integration (thanks to Ubiratan Pires Alberton), but this was then removed after deciding only to maintain integration with Test::Unit and MiniTest which are both Ruby standard libraries. See mailing list message for details.
- Don’t monkey-patch MiniTest if it’s already been monkey-patched by Mocha.
- Fixed bug – MiniTest integration was counting
ExpectationErrorsas errors not failures. - Fixed bug – Some Bacon tests were failing in Ruby 1.9.1.
- Chad Humphries pointed out that in Ruby 1.9.1, if you are not using Test::Unit or MiniTest, Mocha will attempt to load and monkey-patch Test::Unit. Mocha will now only monkey-patch Test::Unit and/or MiniTest if they have already been loaded. MiniTest tests will now run in both Ruby 1.8.6 (with MiniTest gem) and in Ruby 1.9.1 (with MiniTest standard library). See Lighthouse ticket.
- Made Mocha compatible with minitest 1.4.0 and above (thanks to Denis Defreyne).

Unrequiring rubygems for the win!
I’m no longer in Ruby land, though I may one day return, and when I do “require rubygems” will hopefully make me grind my teeth slightly less often.
Forcing a choice of path management on people is a mistake to start with, but when you force people to choose one that is so awful, so fundamentally Bad and Wrong, you make the world sad.
Indeed :-)