On Dec 12, 7:39 pm, David Kahn <[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


> 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

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to