Testing a library, how to auto, autoload

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?

Matt

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

Grab the contents of the folder, then loop through requiring them all.

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO
(#2) OUT NOW!
http://sensei.zenunit.com/