Can't Run UnitTests: no such file to load -- test_helper

Aptana RadRails discussion.

Moderator: Aptana Staff

Can't Run UnitTests: no such file to load -- test_helper

Postby dario_argento87 » Tue Jun 10, 2008 12:25 pm

I just installed RadRails. I am using Rails 2.0.1. When I try to run any rails unit tests. I get the following:

c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- test_helper (LoadError)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from ./test\unit\album_test.rb:1
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from C:/workspace/.metadata/.plugins/org.rubypeople.rdt.testunit/RemoteTestRunner.rb:294

The test runs fine with rake. Here is the code for the test:

require 'test_helper'

class ReviewDetailTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end

Any ideas? I have used Rad Rails in the past and never experienced this.
dario_argento87
 
Posts: 2
Joined: Tue Jun 10, 2008 12:21 pm

Postby cwilliams » Tue Jun 10, 2008 3:24 pm

How are you invoking the test? If you run all unit tests from the toolbar pulldown item, does that work? Does it work in rake and RadRails if you change the "require 'test_helper'" line to "require 'test/test_helper'" at top?
User avatar
cwilliams
 
Posts: 2061
Joined: Thu Mar 29, 2007 11:21 pm
Location: Rochester, NY

Postby dario_argento87 » Tue Jun 10, 2008 6:03 pm

It only runs successfully if I run it using rake. The problem is most likely with the require statement:
require 'test_helper'

I am at work now and I looked at some older code that was using Rails 1.2.6 and the require statement in the unit tests looks like this:
require File.dirname(__FILE__) + '/../test_helper'

It seems like the newer version of rails that I have installed at home, I think its 2.0.1, creates the test case a little differently. I am 99% positive that if I change the require statement to the above it will work. I'll check when I get home
dario_argento87
 
Posts: 2
Joined: Tue Jun 10, 2008 12:21 pm

Same problem

Postby stu2 » Fri Jun 13, 2008 3:33 pm

I just downloaded Aptana, and was able to pull down my current rails project fine. However running any tests from within Aptana produces this:

Code: Select all
./test/unit/abstract_question_test.rb:1:in `require': no such file to load -- test_helper (LoadError)
   from ./test/unit/abstract_question_test.rb:1
   from /Users/stu/Documents/Aptana/.metadata/.plugins/org.radrails.rails.core/run_unit.rb:2:in `load'
   from /Users/stu/Documents/Aptana/.metadata/.plugins/org.radrails.rails.core/run_unit.rb:2
   from /Users/stu/Documents/Aptana/.metadata/.plugins/org.radrails.rails.core/run_unit.rb:2:in `each'
   from /Users/stu/Documents/Aptana/.metadata/.plugins/org.radrails.rails.core/run_unit.rb:2
   from /Users/stu/Documents/Aptana/.metadata/.plugins/org.rubypeople.rdt.testunit/RemoteTestRunner.rb:294:in `require'
   from /Users/stu/Documents/Aptana/.metadata/.plugins/org.rubypeople.rdt.testunit/RemoteTestRunner.rb:294


This happens when I invoke it every way I can find, including "Run As" ::Test. It also happens when I "Run Unit Tests" from the toolbar dropdown.

Tests run fine from Rake and also from within Netbeans.

It looks as though whatever kicks off the test in radrails isn't initializing the load path correctly.
stu2
 
Posts: 12
Joined: Fri Jun 13, 2008 3:28 pm

Comments on the issue

Postby stu2 » Fri Jun 13, 2008 3:39 pm

I just read through http://forums.aptana.com/viewtopic.php? ... testhelper

...hopefully that isn't the final answer. I think tests should run as-is within the ide, and not require users to hard code a reference to libraries outside of /app or /lib (test_helper for instance, or other helpers in /test)

Netbeans had the same issue incidently. See http://www.netbeans.org/issues/show_bug.cgi?id=136650 . It's now fixed in their nightly (though the issue remains when launching under the debugger)

Aptana looks extremely promising. Nice work. Very cool how you're able to leverage the standard eclipse infrastructure in another language.
stu2
 
Posts: 12
Joined: Fri Jun 13, 2008 3:28 pm

Postby cwilliams » Mon Jun 16, 2008 12:58 pm

Hmm, I thought this wasn't broken when you ran all unit tests from the toolbar pulldown. In any case can you open a ticket for whatever cases this doesn't work (like launching individual tests)? http://support.aptana.com/asap
User avatar
cwilliams
 
Posts: 2061
Joined: Thu Mar 29, 2007 11:21 pm
Location: Rochester, NY

Bug posted

Postby stu2 » Mon Jun 16, 2008 1:09 pm

stu2
 
Posts: 12
Joined: Fri Jun 13, 2008 3:28 pm

Postby ehagen » Wed Jul 16, 2008 7:22 am

> require File.dirname(__FILE__) + '/../test_helper'

This worked for me. Thanks!
ehagen
 
Posts: 1
Joined: Wed Jul 16, 2008 7:21 am

Still Failing

Postby cch1 » Thu Jul 17, 2008 4:35 pm

It's not clear to me if issue #ROR-886 is considered resolved because it has been fixed, considered resolved because it is a duplicate (of #ROR-893) or considered outstanding.

My experience shows that it is still outstanding. I have noted this failure in Edge Rails running with the latest Aptana code which my installation downloaded today.

What's the status? And what's the prognosis?

Any workaround OTHER than modifying every test to change the relative load path for test_helper.rb?

This is a big bummer...

I posted a workaround here:

http://cho.hapgoods.com/wordpress/?p=161
cch1
 
Posts: 1
Joined: Thu Jul 17, 2008 4:01 pm

Postby cwilliams » Mon Jul 21, 2008 2:15 pm

It's considered closed because it's a duplicate of ROR-893. But ROR-893 is supposed to be fixed. Are you not seeing this? What version are you on? If you're using 1.0.3 or nightly builds, then please re-open the ticket...
User avatar
cwilliams
 
Posts: 2061
Joined: Thu Mar 29, 2007 11:21 pm
Location: Rochester, NY

still broken

Postby jemminger » Tue Jul 29, 2008 1:51 pm

still broken in 1.0.3 for me: ROR-935 (cloned ROR-893 since I couldn't reopen it)
jemminger
 
Posts: 3
Joined: Fri Dec 14, 2007 5:06 pm


Return to Aptana RadRails