Wednesday, October 7, 2009

Rails: undefined method `use_transactional_fixtures=' in Rails 2.3

Problem: You try to run your Rails tests under Rails 2.3 and you run across the "undefined method `use_transactional_fixtures='" error.
./test/integration/../test_helper.rb:29: undefined method `use_transactional_fixtures=' for Test::Unit::TestCase:Class (NoMethodError)
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from ./test/integration/survey_user_interface_test.rb:1
        from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
        from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
        from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
        from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/usr/bin/ruby.exe -I"lib:test" "/usr/lib/r...]

Fix:
Change the class definition in test_helper.rb from
class Test::Unit::TestCase
to
class ActiveSupport::TestCase