Unit testing /lib directory


I’m writing small replacement for ActiveRecord to support columns
oriented databases (HBase). I put all of my code into /lib folder and
created small rake file into /lib/tasks to support unit testing:

#----- start of file -----
namespace :test do
Rake::TestTask.new(:lib) do |t|
t.libs << “lib”
t.libs << “test”
t.pattern = ‘test/lib/**/*_test.rb’
t.verbose = true
Rake::Task[‘test:lib’].comment = “Run the tests in test/lib”
#---- end of file -------

Now i’m able to write unit tests in /test/lib.

My main problem is that my unit tests now do not see any rails loaded
classes, e.g. one of my unit tests uses ActiveRecord::Errors but i’m
getting :

“NameError: uninitialized constant ActiveRecord::Errors”

Do I need to include (require) all rails classes in my unit tests just
to be sure that everything works fine? (in general I included rubygems
and active_record but still getting same error)? Any ideas,
comments, …?