Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

no such file to load test_helper

#5080

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.

Reported by Matt Simpson · July 10th, 2010 @ 06:48 AM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Henrik Hodne
    Henrik Hodne

    Try ruby -Itest test/unit/city_test.rb. The top line should be require "test_helper". The -Itest adds the test directory to the load path.

    July 10th, 2010 @ 01:19 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • 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.

    July 10th, 2010 @ 02:20 PM

  3. David Morton
    David Morton

    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?

    September 13th, 2010 @ 02:43 AM

  4. Rohit Arondekar
    Rohit Arondekar
    • 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.

    September 13th, 2010 @ 04:42 AM

  5. Rohit Arondekar
    Rohit Arondekar
    • 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.

    September 13th, 2010 @ 05:06 AM

  6. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:57 PM

  7. bingbing