From: KURODA Hiraku <hiraku / sapporo.email.ne.jp>
Subject: [ruby-list:46359] Re: 自前コンパイルしたruby1.9の$LOAD_PATHに"."が入っていない
Date: Sat, 5 Sep 2009 17:16:31 +0900

> 自作ライブラリのテストを"."が含まれている前提で書いていてこの問題に引っかかったのですが、
> やはり仕様だったようです。
> 
> ただ、何か理由(セキュリティ上のもの?)があって外された様なので、"."ではなく__FILE__を使う方が
> 良いのかもしれません。

Kernel#require_relative を使えということでしょうね。

------------------------------------ Kernel#require_relative
     require_relative(path)
------------------------------------------------------------
     require_relative complements the builtin method 
     require by allowing you to load a file that is 
     relative to the file containing the require_relative 
     statement.

     When you use require to load a file, you are usually 
     accessing functionality that has been properly 
     installed, and made accessible, in your system. 
     require does not offer a good solution for loading 
     files within the project's code. This may be useful 
     during a development phase, for accessing test data, 
     or even for accessing files that are "locked" away 
     inside a project, not intended for outside use.

     For example, if you have unit test classes in the 
     "test" directory, and data for them under the test 
     "test/data" directory, then you might use a line like 
     this in a test case:

       require_relative "data/customer_data_1"

     Since neither "test" nor "test/data" are likely to be 
     in Ruby's library path (and for good reason), a normal 
     require won't find them. require_relative is a good 
     solution for this particular problem.

     You may include or omit the extension (.rb or .so) of 
     the file you are loading.

     path must respond to to_str.

--
rubikitch
Blog: http://d.hatena.ne.jp/rubikitch/
Site: http://www.rubyist.net/~rubikitch/
Twit: http://twitter.com/rubikitch/
『Ruby逆引きハンドブック』 http://d.hatena.ne.jp/rubikitch/20090525/rubybook