ActiveSupport::TestCase vs Test::Unit::TestCase when unit testing rails

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.

Answers


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.


Need Your Help

Connecting to external database in iOS

ios database delphi delphi-xe2 firemonkey

I know I can use SQLlite and of course a clientdataset, but....

NoSQL database with high read performances (write accesses are not significant)?

database mongodb node.js nosql redis

I'm working on a "real-time" website using Nodejs. Currently, I'm using Redis because I need high performance for read-access. The write accesses are not really significant for my use case.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.