including files

My spec folder is setup like this:

/spec

/spec/spec_helper.rb

/spec/lib

/spec/lib/some_file_spec.rb

My some_file_spec.rb has:

require ‘spec_helper’

describe “…” do

end

Why does this work even though the spec_helper file is in a folder below the actual file I am writing the specs for?

What techniques are there to include files? I see this also:

require File.expand_path(’…/boot’, FILE)

You could change your spec file to:

require ‘spec_helper’

puts $LOAD_PATH

describe “…” do

and study the output of that puts.

In my case, rather near the end of the list, it has:

/home/peterv/…/<Rails.root>/spec

which explains why the require finds the spec_helper.rb file there.

HTH,

Peter