Why do the generated test files have: require ''test_helper'' It cannot obviously find the file because it''s located in a subdirectory. That''s annoying. -- Posted via http://www.ruby-forum.com/.
It finds it ok for me when run from rake test but not from ruby test/unit/test.rb I change all the require lines to require File.dirname(__FILE__) + ''/../test_helper'' I suspect there is a better way of achieving this effect Colin 2009/5/14 Fernando Perez <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Why do the generated test files have: require ''test_helper'' > > It cannot obviously find the file because it''s located in a > subdirectory. That''s annoying. > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Fernando Perez
2009-May-14 20:50 UTC
Re: Generated test files and bad require ''test_helper''
Colin Law wrote:> It finds it ok for me when run from rake test but not from ruby > test/unit/test.rb > I change all the require lines to > > require File.dirname(__FILE__) + ''/../test_helper'' > > I suspect there is a better way of achieving this effectThanks Colin for your input. Actually it works the same for me (I never noticed), but I often find myself only running a little set of tests and not always the full rake test. -- Posted via http://www.ruby-forum.com/.
Fernando Perez wrote:> Colin Law wrote:>> require File.dirname(__FILE__) + ''/../test_helper'' >> >> I suspect there is a better way of achieving this effect> Thanks Colin for your input. Actually it works the same for me (I never > noticed), but I often find myself only running a little set of tests and > not always the full rake test.Some editors run tests in the "wrong" folder - if they can run unit tests at all - so that File.dirname mishmash is crucial for Rails''s tests. No idea why the newer version took it out! -- Phlip http://flea.sourceforge.net/resume.html
Frederick Cheung
2009-May-14 21:42 UTC
Re: Generated test files and bad require ''test_helper''
On May 14, 10:20 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Fernando Perez wrote: > > Colin Law wrote: > >> require File.dirname(__FILE__) + ''/../test_helper'' > > >> I suspect there is a better way of achieving this effect > > Thanks Colin for your input. Actually it works the same for me (I never > > noticed), but I often find myself only running a little set of tests and > > not always the full rake test. > > Some editors run tests in the "wrong" folder - if they can run unit tests at all > - so that File.dirname mishmash is crucial for Rails''s tests. No idea why the > newer version took it out!Take a look at the comments for http://github.com/rails/rails/commit/e8170805df1a32119db9d328daee1239b338ac71 Fred> > -- > Phlip > http://flea.sourceforge.net/resume.html
Frederick Cheung wrote:>> Some editors run tests in the "wrong" folder - if they can run unit tests at all >> - so that File.dirname mishmash is crucial for Rails''s tests. No idea why the >> newer version took it out! > > Take a look at the comments for http://github.com/rails/rails/commit/e8170805df1a32119db9d328daee1239b338ac71"different relative requires of the same file cause Ruby to load it multiple times. This causes bugs. Fixing it is the point of this change." Then use File.expand_path(File.dirname(__FILE__) + ''/../test_helper.rb''). expand_path - if I spelled it right - goes to the OS filesystem for the uniquely correct path, right? -- Phlip http://flea.sourceforge.net/resume.html
> "different relative requires of the same file cause Ruby to load it multiple > times. This causes bugs. Fixing it is the point of this change." > > Then use File.expand_path(File.dirname(__FILE__) + ''/../test_helper.rb''). > > expand_path - if I spelled it right - goes to the OS filesystem for the uniquely > correct path, right?"File.expand_path doesn’t behave on Windows". It always comes back to that, huh? (-: -- Phlip http://flea.sourceforge.net/resume.html