From: zetetic Date: 2008-01-26T07:24:57+09:00 Subject: Re: Scripts run using load in "for" loop run out of order On Jan 24, 6:06 pm, Phrogz wrote: > On Jan 24, 4:24 pm, brab...@gmail.com wrote: > > > > > On Jan 24, 2008 6:06 PM, wrote: > > > > But, sorry that this doesn't yet work around not knowing the class > > > names just the file names. > > > Maybe: > > > require 'test/unit/ui/console/testrunner' > > > # global array to hold the test classes as they are loaded > > $tests = [] > > > # monkey patch to record the new subclasses as they are loaded > > class Test::Unit::TestCase > > def self.inherited(subclass) > > $tests << subclass > > end > > end > > Or, avoid the global with: > > class Test::Unit::TestCase > class << self > attr_reader :subclasses > def inherited( subclass ) > (@subclasses||=[]) << subclass > end > end > end > > and then > > Test::Unit::TestCase.subclasses.each do |klass| > ... > end Sweet! (or perhaps I should say: suite!)