Hello

I keep wondering if there is a way to have __FILE__ be delayed
in its evaluation. For example, in my tests cases, I usually do the
following so that my test cases are imune to where they are run from:

class TestMyClass < Test::Unit::TestCase

  TEST_DIR = File.dirname(__FILE__)
  DATA_DIR = File.join(TEST_DIR, "data")

  def data_file(file)
    File.join(DATA_DIR, file)
  end

  def test_xyz
    open(data_file("fred"))
    assert ...
  end
end

The problem is I have to add this to every test case since I can't put
data_file inside a module and include it without also having o define
TEST_DIR as a constant of Object inside every testcase.

In other words, I don't want to do:

TEST_DIR = File.dirname(__FILE__)
class TestMyClass < Test::Unit::TestCase
  require 'test_helper'
  include TestHelper
  TestHelper.init __FILE__
end

This just seems a bit verbose.

I guess what I need is something like:  __REQUIRING_FILE__
so my TestHelper module could be written as:

module TestHelper
  TEST_DIR = File.dirname(__REQUIRING_FILE__)
  DATA_DIR = ...as above
end

Has anyone ever needed such a thing? Is there a better way of solving
this problem?

Thanks
-- 
Jim Freeze