The recommended way of avoiding this issue is to use
ruby -I test test/unit/whatever.rb
Apparently putting the dirname in the require can cause all sorts of
issues that I do not understand and we just have to put up with it. (
I don't mean we have to put up with not understanding it).
I must admit that since I have never come across any of those issues I
just put the dirname in. My projects are personal rather than
commercial however so the fact that I may fall over this some day is
my problem only. I think if I were doing a commercial app I would
probably not put the dirname in, and put up with it.
I'm hoping there is a better way? Maybe a fix in edge rails? Anyone
have an update?
The recommended way of avoiding this issue is to use
ruby -I test test/unit/whatever.rb
How to get that inside your rake test script?
Apparently putting the dirname in the require can cause all sorts of
issues that I do not understand and we just have to put up with it. (
I don't mean we have to put up with not understanding it).
require '../foo' and require '../../bar/foo' will both load foo.rb twice. This is usually not what you want, but it's a simplification in the current require system. Because all unit tests should run in the same VM, the ones in different folders will load test_helper again.
Then the second occurrence of require 'test_helper' will not load twice, even if (on some dementedly configured system), the require File.dirname(__FILE__) + '/../test_helper' could have instead loaded a different one.
I just wish I didn't have to keep editing my test files. It sounds
like there still isn't a consensus on a workaround or a fix in the
works from the Rails Core.