[mocha-developer] Fwd: [ mocha-Patches-11583 ] Mocha 0.5.0 throwing unexpected warnings, one line patch included

James Mead james.mead at mail.com
Fri Jun 15 05:49:58 EDT 2007



Begin forwarded message:

> From: <noreply at rubyforge.org>
> Date: 15 June 2007 10:44:07 BDT
> To: noreply at rubyforge.org
> Subject: [ mocha-Patches-11583 ] Mocha 0.5.0 throwing unexpected  
> warnings, one line patch included
>
> Patches item #11583, was opened at 2007-06-14 21:28
> You can respond by visiting:
> http://rubyforge.org/tracker/? 
> func=detail&atid=7479&aid=11583&group_id=1917
>
> Category: None
> Group: None
>> Status: Closed
>> Resolution: Accepted
> Priority: 3
> Submitted By: Glenn Rempe (grempe)
> Assigned to: Nobody (None)
> Summary: Mocha 0.5.0 throwing unexpected warnings, one line patch  
> included
>
> Initial Comment:
> Hello.
>
> The tests for my application run clean with mocha 0.4.0.  I  
> upgraded one of my machines to 0.5.0 with a new install of mocha  
> and suddenly my unchanged tests were throwing a warning like:
>
> mac-mini:~/src/svk/amazon-ec2/trunk/amazon-ec2 glenn$ /usr/local/ 
> bin/ruby -w -Ilib:ext:bin:test -e 'require "test/test_EC2.rb";  
> require "test/test_EC2_console.rb"; require "test/ 
> test_EC2_image_attributes.rb"; require "test/test_EC2_images.rb";  
> require "test/test_EC2_instances.rb"; require "test/ 
> test_EC2_keypairs.rb"; require "test/test_EC2_responses.rb";  
> require "test/test_EC2_security_groups.rb"; require "test/ 
> test_EC2_version.rb"; require "test/test_helper.rb"; require "test/ 
> unit"'
> Loaded suite -e
> Started
> ..../usr/local/lib/ruby/gems/1.8/gems/mocha-0.5.0/lib/mocha/mock.rb: 
> 151: warning: instance variable @responder not initialized
> /usr/local/lib/ruby/gems/1.8/gems/mocha-0.5.0/lib/mocha/mock.rb: 
> 151: warning: instance variable @responder not initialized
> /usr/local/lib/ruby/gems/1.8/gems/mocha-0.5.0/lib/mocha/mock.rb: 
> 151: warning: instance variable @responder not initialized
>
> This seems to be related to the fact that I am not calling a new  
> method in 0.5.0 Mock#responds_like in mock.rb in my tests.  Since I  
> never call this in my tests the @responder instance variable is  
> never set and the method_missing call throws a warning since you  
> are doing a test on an unset variable.
>
> Not sure if this is the perfect fix or not, but when I defined  
> @responder = nil in the initialization of the mock.rb file all  
> warnings in my tests went away and all of your tests still pass.
>
> Please take a look at the single line patch for implementation and  
> please also enhance the documentation and examples to show how  
> responds_like is supposed to be used.
>
> Thanks,
>
> Glenn
>
> ----------------------------------------------------------------------
>
>> Comment By: James Mead (jamesmead)
> Date: 2007-06-15 09:44
>
> Message:
> Many thanks. You are quite right. I had forgotten about the  
> responds_like functionality. I'm not 100% sure it's complete! I've  
> fixed the warning and switched warnings on in the rake test tasks  
> to highlight similar problems in the future. I've published a new  
> set of files for version 0.5.1 to include this fix (http:// 
> rubyforge.org/frs/?group_id=1917).
>
> In what way do you think the rdoc for responds_like is not  
> complete? http://mocha.rubyforge.org/classes/Mocha/Mock.html#M000029
>
> Thanks again for your input.
>
> ----------------------------------------------------------------------
>
> You can respond by visiting:
> http://rubyforge.org/tracker/? 
> func=detail&atid=7479&aid=11583&group_id=1917



More information about the mocha-developer mailing list