Rails: Upgrading test_helper.rb for Rails 2.3
Keen to be using the latest code and features of Rails, I installed Rails 2.3 for development today. So far, most of the app has worked fine after a running a rake rails:update. However, today I came across an error when running my unit tests:
$ rake test:units
/usr/bin/ruby1.8 -Ilib:test "/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" "test/unit/client_test.rb"
./test/test_helper.rb:22: undefined method `use_transactional_fixtures=' for Test::Unit::TestCase:Class (NoMethodError)
rake aborted!
To see what was going on, I created a new rails app and checked out the default test_helper.rb. It seems the TestCase class has been moved from Test::Unit into ActiveSupport:
# test_helper.rb (Rails 2.2 - doesn't work in 2.3)
class Test::Unit::TestCase
# ...
end
# test_helper.rb (Rails 2.3)
class ActiveSupport::TestCase
# ...
end
After this quick change, the tests were back up and running.
blog comments powered by
Disqus