views:

164

answers:

1

I recently noticed my test database is not being cleaned up after my tests run if my tests subclass Test::Unit::TestCase. If my tests subclass ActiveSupport::TestCase, everything is cleaned up properly.

Can anyone explain why, and/or provide an explanation of using one versus the other?

I am using shoulda and factory_girl.

Thanks.

+1  A: 

If you take a look at the code, you'll see ActiveSupport::TestCase has a lot of of setup and utility functions for testing Rails. Older versions of Rails used to use Test::Unit::TestCase with a lot of mixins, but moved to subclassing a while ago.

If you're testing a Rails app, you should subclass ActiveSupport::TestCase or ActionController:TestCase for controllers. The generators will do this automatically, so you should not have to think about it most of the time.

Luke Francl