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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
This is a commonly used convention: # # Yes, the double "../" are needed if requiring "../spec_helper.rb" this 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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 1, 1:38 am, Alex Katebi <alex.kat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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! > Alex-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks so much! The require_relative is much cleaner. 1.9 works for me. On Fri, Apr 1, 2011 at 12:27 PM, Kendall Gifford <zettabyte-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > This is a commonly used convention: > > # > # Yes, the double "../" are needed if requiring "../spec_helper.rb" this > 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. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
This worked too. Even better. Thanks! On Fri, Apr 1, 2011 at 1:57 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 1, 1:38 am, Alex Katebi <alex.kat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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! > > Alex > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
This worked too. Even better. Thanks! On Fri, Apr 1, 2011 at 1:57 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 1, 1:38 am, Alex Katebi <alex.kat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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! > > Alex > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.