[mocha-developer] Mocha and rails 2.0.2?

Ned Wolpert ned.wolpert at gmail.com
Fri Dec 21 11:02:52 EST 2007


Folks-

  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...

Is it me?

-- 
Virtually, Ned Wolpert
http://www.codeheadsystems.com/blog/

"Settle thy studies, Faustus, and begin..."   --Marlowe


More information about the mocha-developer mailing list