In Test/Unit Dir.glob is Rails root but to require a file must assume "Rails_root/test/"

I am wondering why this is: In Test/Unit I am iterating a directory so
that
I can require each of the files in the directory.

When I call Dir.glob, the root is the Rails_root, however when I iterate
the
files I get an error if I use Rails root and must begin the included
file’s
path from within the test directory.

This:

integration/helpers/file.rb

And not

test/integration/helpers/file.rb

I assume this is due somehow to Test/Unit running and having its own
assumed
root directory in “test/” and not Rails root.

So is there a prettier method of doing this"

Dir.glob("test/integration/helpers/.rb").each do |helper_file|
require helper_file.gsub(/test//, ‘’) # for some reason the
Dir.glob
starts at rails root but when requiring, it starts within test/

end

On Dec 12, 7:39pm, David K. [email protected] wrote:

I am wondering why this is: In Test/Unit I am iterating a directory so that
I can require each of the files in the directory.

When I call Dir.glob, the root is the Rails_root, however when I iterate the
files I get an error if I use Rails root and must begin the included file’s
path from within the test directory.

Require interprets paths relative to those folders on the load path.
The root of the rails app isn’t on the load path, but test is, hence
require ‘test/integration/helpers/file’ doesn’t work, but require
‘integration/helpers/file’ does.
If you added that folder to load_paths & eager_load_paths then rails
would require those files for you

Fred