From: Joel VanderWerf Date: 2008-04-03T02:21:54+09:00 Subject: Re: Testing a library, how to auto, autoload goodieboy wrote: > Hi, > > I'm writing some tests for a library, and don't want to "require" > every single module/class. Anyone know if a quick way to set autoload > for all modules/classes for library? If you have some way of recognizing the names of your classes (such as a regex), you could adapt the following: if false autoload :FileUtils, "fileutils" else class << Object alias old_const_missing const_missing def const_missing name case name.to_sym when :FileUtils; require "fileutils"; FileUtils else old_const_missing name end end end end class A def foo p FileUtils end end A.new.foo -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407