[Rubygems-developers] Failing to test gem on install

Gavin Sinclair gsinclair at soyabean.com.au
Sat Jul 17 11:47:20 EDT 2004


Guys, I'm not sure if anyone _really_ knows what's going on with gem
test-on-install :)

This is the pertinent part of the code (InstallCommand#execute):

          require_gem gem.name, "= #{gem.version.version}"
          require gem_spec.test_suite_file
          suite = Test::Unit::TestSuite.new("#{gem.name}-#{gem.version}")
          ObjectSpace.each_object(Class) do |klass|
            suite << klass.suite if (klass < Test::Unit::TestCase)
          end

Basically, the gem (already installed) is loaded, and then the test
suite file from that gem is *require*d.  That means the test suite
file must be part of the lib path, which I don't think is right.

Then a Test::Unit::TestSuite is built up from all TestCase classes in
the object space.

So what would such a test_suite_file look like?  A bunch of require
statements by the sound of it.  Is this a committed design decision?

Basically, unit testing of gems hasn't been commonplace.  I'm trying
to work out from the source how I'm supposed to unit test my own gem,
and would appreciate some suggestions.

Cheers,
Gavin



More information about the Rubygems-developers mailing list