Require_relative doesn't work for nested includes

(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?