[mocha-developer] Mocha and rails 2.0.2?

James Mead jamesmead44 at gmail.com
Fri Dec 21 18:56:38 EST 2007


On 21/12/2007, Ned Wolpert <ned.wolpert at gmail.com> wrote:
> > On Dec 21, 2007 8:02 AM, Ned Wolpert <ned.wolpert at gmail.com> wrote:
> > >  With Rails 2.0.2, I'm seeing mocha failures where they did not fail
> > > with Rails 2.0.1
> > >
> > > test_set_to_process_fail_in_transaction(FileRecordTest):
> > > NoMethodError: undefined method `ord' for 63:Fixnum
> > >
> > >  /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/class_method.rb:45:in
> > > `hidden_method'
> > >
> > >  /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/class_method.rb:45:in
> > > `gsub'
> > >
> > >  /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/class_method.rb:45:in
> > > `hidden_method'
> > >
> > >  /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/class_method.rb:29:in
> > > `hide_original_method'
> > >
> > >  /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/class_method.rb:14:in
> > > `stub'
> > >
> > >  /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/central.rb:13:in
> > > `stub'
> > >
> > >  /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/object.rb:40:in
> > > `expects'
> > >    test/unit/file_record_test.rb:90:in
> > > `test_set_to_process_fail_in_transaction'
> > > ...
> > >
> > > In this case, the line that is blowing up is this one:
> > >
> > >    File.expects(:exists?).times(2).returns(true)
> > >
> > > and fails with this too...
> > >
> > >    File.expects(:exists?).returns(true)
> > >
> > > further checking show it fails with stubs, like this...
> > >
> > >    File.stubs(:exists?).returns(true)
> > >
> > > Note I can stub or expect other methods, like save! or even 'new'..
> > > the following works fine...
> > >
> > >    File.expects(:new).returns(file)
> > >
> > > Its possible I'm not doing this in a way that makes sense...
> > > specifically, I want to stub out the method 'exists?' to return true
> > > when its called twice. Again, it worked fine in all rails versions up
> > > to 2.0.2, and only fails with rails 2.0.2...

Hi Ned,

I'm assuming you're using the Mocha Rails plugin with svn:externals
i.e. you had picked up revision 206 from Mocha trunk when this error
started occurring - is that correct?

I think I just re-created your bug and I've realised there was a
mistake in Mocha changeset 206. I've just committed what I think is a
fix in revision 207. Can you let me know if this fixes your problem?

Thanks for reporting the bug.

-- 
James.
http://blog.floehopper.org
http://tumble.floehopper.org


More information about the mocha-developer mailing list