April 21, 2007

Rails and SCRIPT_LINES

After reading a great tutorial on debugging in Rails with ruby-debug, I inserted the following line at the end of my config/environment.rb


SCRIPT_LINES__ = {} if (ENV['RAILS_ENV'] == 'development' || ENV['RAILS_ENV'] == 'test')

which had been working just fine for me. Ruby-debug is a great debugger and has helped me track down a lot of tricky issues (and works more consistently for me than the built-in debugger within RadRails).

However, today I ran into a weird problem - tried to install rcov and the rails rcov plugin. But when I tried


$ rake test:units:rcov

I got the following:


...
...
Loaded suite /opt/local/bin/rcov
Started
....................................
Finished in 4.366043 seconds.

36 tests, 114 assertions, 0 failures, 0 errors
+----------------------------------------------------+-------+-------+--------+
| File | Lines | LOC | COV |
+----------------------------------------------------+-------+-------+--------+
+----------------------------------------------------+-------+-------+--------+
|Total | 0 | 0 | 0.0% |
+----------------------------------------------------+-------+-------+--------+
0.0% 0 file(s) 0 Lines 0 LOC

No file to analyze was found. All the files loaded by rcov matched one of the
following expressions, and were thus ignored:
...
...
...

What's going on here? After playing around for awhile, I tried commenting out the SCRIPT_LINES line above and bingo! everything worked.

After a bit of searching, I found a comment on this ruby-debug tutorial that states that the SCRIPT_LINES constant no longer needs to be defined for ruby-debug to work. I briefly tried ruby-debug without defining the constant and everything seemed fine.

So if you find yourself facing some weirdness with rcov or any other Rails plugin, send that SCRIPT_LINES constant packing and see if that helps.

Posted by Ben at April 21, 2007 5:57 PM
Comments
Post a comment










Remember personal info?