Rails and SCRIPT_LINES

by

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.

Advertisements

One Response to “Rails and SCRIPT_LINES”

  1. roger Says:

    why would that make a difference though? Does it still?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: