Tuesday, March 23, 2010

Surviving Test::Unit::TestResult::TestResultFailureSupport

I've been developing a number of applications in Ruby recently. One of these was ready for a Rails upgrade so I thought, let's go all the way to 2.3.5 (from 2.1) and see what happens.

Big Mistake!
Or so I thought!

What happened? My tests failed! Not only did they fail, the exception comes directly from the autorunner.rb class of the test-unit gem. Not from one of my classes. My code isn't touched!

Limited help on the sites...

Immediately I lept for my browser and started googling. Everything I turned up was full of conjecture and appeared to land on the "thoughtbot/shoulda" gems. But I don't use them, so they weren't causing my problem.

It turns out the cause was right in front of me. The error is coming out of the test-unit gem. Not from my code. Not from rails.

In Rails 2.3.5 (and maybe before), Rails introduced their own test-unit and started using ActiveSupport::TestUnit instead of Test::Unit::TestUnit.

So what was happening?

The test-unit gem is taking precedence and wreaking havoc.

The Solution!!!!

Uninstall the test-unit gem.

No comments: