rails/ruby test - error report without line numbers

Hi all,

I'm new to Rails and new to Rails testing. I have a few questions:

First, the most important question. How do I get line numbers to be reported with my errors when testing. Here is what I get back on a typical error:

josh@josh-laptop:~/d/test$ ruby unit/line_test.rb -n test_update Loaded suite unit/line_test Started E Finished in 0.066663 seconds.

  1) Error: test_update(LineTest): NameError: undefined local variable or method `sdf' for #<LineTest:0xb6e61304>

1 tests, 0 assertions, 0 failures, 1 errors

It is tough to debug without a line number and filename. From the code samples I've seen, people generally get back a more verbose error report. How do I enable this?

The next question is a small one. What is the difference between: -ruby unit/line_test.rb -ruby test -I unit/line_test.rb -ruby test unit/line_test.rb

I'd like to know the difference since I'm unable to use the command in the Rails Testing guide (third one).

Thanks!

Josh

Joshua S. wrote in post #970342:

Hi all,

I'm new to Rails and new to Rails testing. I have a few questions:

First, the most important question. How do I get line numbers to be reported with my errors when testing.

<soapbox>   Probably by not using Test::Unit. :slight_smile: It sucks. Try RSpec instead. Better API and much more readable error reports. </soapbox>

Best,

I posted an unpleasant solution on stackoverflow:

Hi all,

I'm new to Rails and new to Rails testing. I have a few questions:

First, the most important question. How do I get line numbers to be reported with my errors when testing. Here is what I get back on a typical error:

josh@josh-laptop:~/d/test$ ruby unit/line_test.rb -n test_update Loaded suite unit/line_test Started E Finished in 0.066663 seconds.

1) Error: test_update(LineTest): NameError: undefined local variable or method `sdf' for #<LineTest:0xb6e61304>

1 tests, 0 assertions, 0 failures, 1 errors

It is tough to debug without a line number and filename. From the code samples I've seen, people generally get back a more verbose error report. How do I enable this?

I suggest running from your app root. What happens if you do ruby -I test test/unit/line_test.rb

The next question is a small one. What is the difference between: -ruby unit/line_test.rb

That will only work if you run from the test folder, in fact I am surprised it works at all as I don't know how it finds the app environment.

-ruby test -I unit/line_test.rb

That should be '-I test' not 'test -I' . It tells it to Include the folder test in the search path, so that require 'test_helper' at the top of the test file finds test/test_helper.rb

-ruby test unit/line_test.rb

I don't think this would ever work.

Colin