[Rubygems-developers] Failing to test gem on install

Chad Fowler chad at chadfowler.com
Sat Jul 17 12:14:59 EDT 2004

On Sun, 18 Jul 2004, Gavin Sinclair wrote:

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

I do. :)

# 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.

It's not right.  *You* are right, but the behavior isn't. I seem to
remember having fixed this at one point, but it's obviously not fixed now.
I may be daydreaming.

# 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?

Any file that causes TestCases to be defined will work.  This means it can
be a list of requires or a single-file set of tests.  Whatever you like.
For small projects, it might make sense to include all of the tests in the
test_suite_file, while for larger ones you could just require all of your
"tc_*.rb" files from the central file.


More information about the Rubygems-developers mailing list