Ruby 1.8.5/6 and Rails 1.2.3 on Mac OS X 10.4.9 (Intel)

I have encountered a very strange error thanks to my unit tests. I am developing an application on a MacBook Pro running Mac OS X 10.4.9, having installed Ruby, Rails, RubyGems, Mongrel, MySQL, and Subversion based on Hivelogic's instructions at Dan Benjamin

My rails installation is located in my project's vendor/rails directory with rails *not installed* via gems on either computer.

Everything installed fine and everything seems to run fine. However, I encountered a few peculiar errors.

Running 'rake test' on my MacBook Pro would result in successfully passing tests. However, when I checked out my project on my FreeBSD development box, running 'rake test' turned up numerous errors.

I added some more tests and checked some existing ones and it turned out that my MacBook Pro wasn't catching assertions or errors that it should have.

One error that showed up on both machines was in an integration test which was using the 'put' method.

On my MacBook Pro:

  1) Error: test_edit_already_processed_po(BuyerTest): NoMethodError: undefined method `recycle!' for #<ActionController::CgiRequest:0x3360b98>     /Users/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/cgi_process.rb:140:in `method_missing'     /Users/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/test_process.rb:370:in `process'     /Users/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/test_process.rb:353:in `put'     buyer_test.rb:142:in `test_edit_already_processed_po'     /Users/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/integration.rb:453:in `run'

On the FreeBSD Box:

  1) Error: test_edit_already_processed_po(BuyerTest): NoMethodError: undefined method `recycle!' for #<ActionController::CgiRequest:0x98e9bb8>     /usr/home/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/cgi_process.rb:140:in `method_missing'     /usr/home/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/test_process.rb:370:in `process'     /usr/home/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/test_process.rb:353:in `put'     buyer_test.rb:142:in `test_edit_already_processed_po'     /usr/home/username/svn/p2/config/../vendor/rails/actionpack/lib/ action_controller/integration.rb:453:in `run'

I found the dev.rubyonrails.org ticket associated with this error at http://dev.rubyonrails.org/ticket/6353

In the third comment, the user caboose, comments that if your installation is broken you'll see one set of errors, but if your installation works, you will see an extra set of errors... both my MacBook Pro and my FreeBSD box show the first set of errors, which according to caboose, means my installation is broken on both of my machines. However, both machines still report back different results on other tests, some that succeed on my MacBook still fail on my FreeBSD box, with the FreeBSD box being correct on the errors that I have checked. Unfortunately, caboose doesn't point to what the problem could be or any sort of solution.

Continuing with the perspective that my FreeBSD install was at least *more correct* than my MacBook install, I focused on one test in particular where it failed on my MacBook but succeeds on my FreeBSD box. This is a simple 'validates_presence_of :created_by, :on => :create' which does not add an error to the object when it should on my MacBook, but succeeds in adding an error on my FreeBSD box as it should.

MacBook Pro:

Loaded suite test/unit/location_test Started ...F... Finished in 0.093381 seconds.

  1) Failure: test_should_require_created_by(LocationTest) [test/unit/ location_test.rb:38]: <nil> is not true.

7 tests, 18 assertions, 1 failures, 0 errors

FreeBSD Server:

Loaded suite test/unit/location_test Started ....... Finished in 0.142679 seconds.

7 tests, 18 assertions, 0 failures, 0 errors

Again, the FreeBSD server is the correct result. The MacBook Pro is incorrect.

I installed identical versions of ruby, mysql, and rake on my MacBook Pro to match the FreeBSD server. The results are the same.

I installed Ruby 1.8.6 on the MacBook Pro, same results. I reinstall Ruby 1.8.5 without readline, same results, without pthreads, same results.

So, time to run rail's tests to see if they throw any different errors.

MacBook Pro:

rake test (in /Users/username/svn/p2/vendor/rails/railties) Loaded suite test/dispatcher_test Started FF... Finished in 0.148324 seconds.

  1) Failure: test_ac_subclasses_cleared_on_reset(DispatcherTest)     [test/dispatcher_test.rb:139:in `assert_subclasses'      test/dispatcher_test.rb:45:in `test_ac_subclasses_cleared_on_reset']: ["DispatcherControllerTest"]. <0> expected but was <1>.

  2) Failure: test_am_subclasses_cleared_on_reset(DispatcherTest)     [test/dispatcher_test.rb:139:in `assert_subclasses'      test/dispatcher_test.rb:54:in `test_am_subclasses_cleared_on_reset']: ["DispatcherTestMailer"]. <0> expected but was <1>.

5 tests, 19 assertions, 2 failures, 0 errors rake aborted! Failures

FreeBSD Server:

rake test (in /usr/home/username/svn/p2/vendor/rails/railties) Skipping dispatcher tests. `gem install mocha` and try again. Loaded suite test/fcgi_dispatcher_test Started

Finished in 0.000244 seconds.

0 tests, 0 assertions, 0 failures, 0 errors Loaded suite test/plugin_test Started ........... Finished in 0.022597 seconds.

11 tests, 20 assertions, 0 failures, 0 errors Loaded suite test/rails_generator_test Started ......FF.. Finished in 0.08259 seconds.

  1) Failure: test_named_generator_attributes(RailsGeneratorTest) [test/ rails_generator_test.rb:108]: <"foos"> expected but was <"admin_foos">.

  2) Failure: test_named_generator_attributes_without_pluralized(RailsGeneratorTest) [test/rails_generator_test.rb:115]: <"foo"> expected but was <"admin_foo">.

10 tests, 35 assertions, 2 failures, 0 errors rake aborted! Failures

Nice to get some different results, but they still fail.

This is where I am at now. If anyone has any advice, please let me know.

Cheers.

I've moved onto trying to simply check out rails from its repository and run its tests, however even this is unclear.

Following the directions under Creating a patch at http://dev.rubyonrails.org/ i have checked out the 1-2-stable branch, but it's not clear how to run the unittests... activerecord has its own set, which I have run successfully (albeit it reported 1 failure and 1 error), and running 'rake test' and 'rake regular_test' under railties throws a number of errors and failures...

Anyone know what the wiki expects you to do when it states, "Ensure that the existing unit tests pass"? Because all of the tests I could find fail in some way or another.

Update on Rails own tests...

Check out http://hasmanythrough.com/layingtracks/ for a good overview.

Rails does not have its own single rakefile to test everything all at once. I do not know why this is.

You must test each package individually (actionpack, activerecord, etc).

The tests in railties are "supposed" to fail. Meaning, they have been neglected and fail for everyone (I assume).

I contacted the author of Laying Tracks (link above), and he indicated that an updated version of this material will be created next month and hopefully live on the dev.rubyonrails.org wiki. Cheers to that.

I have solved my own problem which turned out to be an incorrect migration of the database structure in the development and test environments on my MacBook. I discovered this by analyzing the DB structure between my local machine and my FreeBSD box. Not sure why this was the case... if it happens again I will debug, but for now if you encounter the same problem, check your database structures!

Cheers.