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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Dec-23 17:44 UTC
Re: rails/ruby test - error report without line numbers
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. :) It sucks. Try RSpec instead. Better API and much more readable error reports. </soapbox> Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I posted an unpleasant solution on stackoverflow: http://stackoverflow.com/questions/4521203/ruby-tests-error-messages-dont-include-line-numbers-or-file-name/4521275#4521275 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 December 2010 17:40, Joshua S. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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.rbThat 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.rbThat 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.rbI don''t think this would ever work. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.