Forum: Ruby require_relative doesn't work for nested includes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3a81ced4012650ca2004c9bff7b18202?d=identicon&s=25 Ronald F. (rovf)
on 2014-08-16 15:33
(Crossposting note: I've also posted this question at

I am writing rspec tests. Some of the classes I'm testing are located in
a directory, which I would prefer by specifying a relative path. I
therefore wrote something like this:

   # Location of the class files relative to the rspec directory

   # Load a class file
   require_relative PICKER_DIR+'/pickercomposer.rb'

Now, the problem is that pickercomposer.rb itself uses a

  require 'picker.rb' # Assumed to be in the same directory as

and assumes that RUBYLIB has been set accordingly. If pickercomposer.rb
would do a

  require_relative 'picker.rb'

everything would be fine, but pickercomposer.rb was written (and is
still used) occasionally with Ruby 1.8.7, which did not have a
require_relative function.

What is the best workaround? Do I need to setup RUBYLIB, before
executing my rspec test, or is there a neat way to achive the goal from
inside the rspec file?
This topic is locked and can not be replied to.