Ruby require 'file' and relative location Ruby require 'file' and relative location ruby ruby

Ruby require 'file' and relative location


You don't. requires are relative to the current directory, which in your case was GUI_Tests/Tests. If you did this instead:

cd ..spec -r upload_tool -fs Test/test_spec.rb

You would have to use this:

require 'windows_gui' # without '../'

The most common way to get around that problem is using File.dirname(__FILE__):

require File.join(File.dirname(__FILE__), '..', 'windows_gui')

NOTE: in Ruby 1.9.2 require changed it's defaults: Ruby: require vs require_relative - best practice to workaround running in both Ruby <1.9.2 and >=1.9.2