Em 05-04-2013 20:41, Tanaka Akira escreveu:
> 2013/4/6 Aaron Patterson<tenderlove / ruby-lang.org>:
>> Can you give me a specific example of how you're running the tests?  It
>> seems we should make sure the load path is always correct rather than
>> couple the source file to it's location in the file system.
> In general, require_relative is a good tool to require a utility
> library for a test.
>
> For example, test/objspace/test_objspace.rb uses test/ruby/envutil.rb.
> But I want to invoke the test as follows.
>
> % ./ruby test/objspace/test_objspace.rb
>
> Since test/ruby/ is not a standard library location,
> the load path doesn't contain it.
>
> So, if "require" is used instead of "require_relative",
> I need to invoke ruby with -Itest/ruby or test_objspace.rb needs to
> tweak the load path which is irritative.

I agree. I tend to often use require_relative in my specs very often and 
I do believe it is a good pattern. Actually I also use require_relative 
in some libraries as well. I find it easier in lots of cases to be 
sure/explicit about what file I'm loading and avoid any search-path 
related confusion.

The reason most tests use require is probably because require_relative 
didn't exist until recently.