This project is archived and is in readonly mode.
no such file to load test_helper
Reported by Matt Simpson | July 10th, 2010 @ 06:48 AM
When running unit test individually via
$ ruby test/unit/city_test.rb
I get:
test/unit/city_test.rb:1:in `require': no such file to load -- test_helper (LoadError)
from test/unit/city_test.rb:1:in `<main>'
$ ruby -v
ruby 1.9.2dev (2010-07-02 revision 28524) [x86_64-darwin10.4.0]
$ rails -v
Rails 3.0.0.beta4
in city_test.rb I have:
require "test_helper"
class CityTest < ActiveSupport::TestCase
test "the truth" do
assert false
end
end
i've tried variations of using require "../test_helper", adding the .rb extension and adding File.dirname(FILE) to the front of the require and same results.
Comments and changes to this ticket
-
Henrik Hodne July 10th, 2010 @ 01:19 PM
Try
ruby -Itest test/unit/city_test.rb
. The top line should berequire "test_helper"
. The-Itest
adds the test directory to the load path. -
Rohit Arondekar July 10th, 2010 @ 02:20 PM
- State changed from new to invalid
- Importance changed from to Low
If Henrik's advice doesn't work, make a comment and I'll reopen.
-
David Morton September 13th, 2010 @ 02:43 AM
Why is this invalid? This fails for me too:
cd test ruby unit/user_test.rb <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- test_helper (LoadError)
According to http://guides.rubyonrails.org/testing.html#running-tests this should work, but I have to add
-I.
to make that work. What changed? -
Rohit Arondekar September 13th, 2010 @ 04:42 AM
- State changed from invalid to open
It won't work without the -I because test is not in the load path. To add it to the load path you need to use -Itest. The error is quite self explanatory, it can't find the file test_helper — it's because test is not in the load path.
However I think now the docs need fixing. I'll see what I can do. Thanks David.
-
Rohit Arondekar September 13th, 2010 @ 05:06 AM
- State changed from open to resolved
Guide edited here http://github.com/lifo/docrails/commit/3683745cbc94a60e1cf60d86c9cb...
This will merged with the main Rails repo after review later.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>