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)

On Sat, Feb 18, 2012 at 7:06 PM, S Ahmed [email protected] wrote:

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:

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


*** Available for a new project ***

Peter V.
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v