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.
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.
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 P. [email protected]
Colin L. 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 torequire 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.
Fernando P. wrote:
Colin L. 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
Frederick C. 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 Generated tests rely on test dir in load path rather than File.dirnam… · rails/rails@e817080 · GitHub
“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?
On May 14, 10:20 pm, Phlip [email protected] wrote:
- 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
Fred
“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? (-:
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