Thursday, 21 October 2010

Ruby on Rails : uninitialized constant Test::Unit::TestSuite

I'm working on a side-project to learn how to work Ruby on Rails using the tutorial written by Michael Hartl to guide me. I think it is an excellent reference and would thoroughly recommend it. Anyway, the reason for this post is to supply the fix for a problem that held me up for a while in the hope that it might save someone else some pain. For reasons too laborious to go into I ended up with the following error when trying to run my RSpec tests after upgrading to Ruby 1.9.2.

/Users/gbarrs/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:440:in `rescue in load_missing_constant': uninitialized constant Test::Unit::TestSuite (NameError)

The fix in my case was to add the the following 'require' statement to the rb spec file causing the error.

require 'test/unit/testsuite'

I have no idea why this line was required when the tests had been working perfectly well before the upgrade without it. I suspect some dependency versioning issue but I can't be sure. Anyway, the fix worked for me and it may work for you.

1 comment:

  1. Added

    config.gem 'test-unit', :lib => 'test/unit'

    to config/environment.rb

    works for me. Don't know enough about Ruby to know why!

    ReplyDelete