How to I handle loading files with relative path?
For example:
require ‘…/spec_helper.rb’
require ‘/home/user/myapp/spec/spec_helper.rb’
Thanks!
Alex
How to I handle loading files with relative path?
For example:
require ‘…/spec_helper.rb’
require ‘/home/user/myapp/spec/spec_helper.rb’
Thanks!
Alex
This is a commonly used convention:
way
require File.expand_path("…/…/spec_helper.rb", FILE)
If using ruby 1.9, I know there is #require_relative but I’ve never
really
used it yet.
On Apr 1, 1:38am, Alex K. [email protected] wrote:
How to I handle loading files with relative path?
For example:
require ‘…/spec_helper.rb’
require ‘/home/user/myapp/spec/spec_helper.rb’
assuming this is in the context of rspec, with the current version
just require ‘spec_helper’ will do (because rspec sticks the spec
folder into the load path)
Fred
Thanks so much! The require_relative is much cleaner. 1.9 works for me.
This worked too. Even better. Thanks!
On Fri, Apr 1, 2011 at 1:57 PM, Frederick C.
<[email protected]
This worked too. Even better. Thanks!
On Fri, Apr 1, 2011 at 1:57 PM, Frederick C.
<[email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs