Hi all, We just updated to the latest version of Mocha and now we''re seeing a lot of odd test failures. If this isn''t the appropriate place for a question like this, please let me know. Say I have code like this in a controller: DataMonitor.toggle_notification! And I mock it like this: DataMonitor.any_instance.stubs(:toggle_notification!) This would work fine with Mocha 0.4.0, but with 0.5.0 it looks like Mocha is differentiating between a method call with parenthesis to one without parenthesis. I don''t really understand how this could happen, nor the logic in why parenthesis should be required for an empty parameter list, so if somebody could explain it to me that''d be awesome. For reference, this is the failure we''re now seeing: #<Mock:0x3308718>.toggle_notification!() - expected calls: 0, actual calls: 1 Similar expectations: toggle_notification! The release notes at the API site (http://mocha.rubyforge.org/files/ RELEASE.html) have not been updated, so I wasn''t able to determine the reason behind this change on my own. Thanks for Mocha, I love it, but for now am sticking with the 0.4.0 release. -justin
Hi Justin, I just tried to reproduce your error... require ''test/unit'' require ''rubygems'' require ''mocha'' class MyTest < Test::Unit::TestCase class DataMonitor def toggle_notification! end end def test_me DataMonitor.any_instance.stubs(:toggle_notification!) DataMonitor.new.toggle_notification! end end This seems to work fine for me. Can you try to distil one of your failing tests down to make it as simple and self-contained as you can, but still exhibiting the error? We need to reproduce the bug before we can fix it. Also can you tell us how you are including Mocha in your project? e.g. Rails plugin, Ruby gem, etc. Sorry about the missing release notes - I''ll try and get that sorted asap - in the meantime this blog post pretty much covers it - http://blog.floehopper.org/articles/2007/06/08/mocha-0-5-released. -- James. http://blog.floehopper.org
> Can you try to distil one of your failing tests down to make it as > simple > and self-contained as you can, but still exhibiting the error? We > need to > reproduce the bug before we can fix it.In trying to make a small, reproducible test case (that passed every time) I discovered an error (surprise) in our code that wasn''t discovered by the previous version of Mocha. This new exception led me to wrongly accuse Mocha. All is well and we are happily using 0.5.0 now.> Also can you tell us how you are including Mocha in your project? > e.g. Rails > plugin, Ruby gem, etc.It''s a Rails project, using the Mocha gem.> Sorry about the missing release notes - I''ll try and get that > sorted asap - > in the meantime this blog post pretty much covers it - > http://blog.floehopper.org/articles/2007/06/08/mocha-0-5-released.Thanks for that, hadn''t seen that yet. -justin On Jun 12, 2007, at 1:32 PM, James Mead wrote:> Hi Justin, > > I just tried to reproduce your error... > > require ''test/unit'' > require ''rubygems'' > require ''mocha'' > > class MyTest < Test::Unit::TestCase > > class DataMonitor > def toggle_notification! > end > end > > def test_me > DataMonitor.any_instance.stubs(:toggle_notification!) > DataMonitor.new.toggle_notification! > end > > end > > This seems to work fine for me. > > Can you try to distil one of your failing tests down to make it as > simple > and self-contained as you can, but still exhibiting the error? We > need to > reproduce the bug before we can fix it. > > Also can you tell us how you are including Mocha in your project? > e.g. Rails > plugin, Ruby gem, etc. > > Sorry about the missing release notes - I''ll try and get that > sorted asap - > in the meantime this blog post pretty much covers it - > http://blog.floehopper.org/articles/2007/06/08/mocha-0-5-released. > -- > James. > http://blog.floehopper.org > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer
On 12/06/07, Justin Perkins <justin at spiceworks.com> wrote:> > In trying to make a small, reproducible test case (that passed every > time) I discovered an error (surprise) in our code that wasn''t > discovered by the previous version of Mocha. This new exception led > me to wrongly accuse Mocha. All is well and we are happily using > 0.5.0 now. >Cool. -- James. http://blog.floehopper.org