At the time of this posting, the latest gem release of RedGreen has a bug. For those of you who don’t know, RedGreen is a handy tool to make specs/unit tests color according to the result of the test to make your testing output much easier to read. Unfortunately, at the time of this posting, the latest gems (Autotest, RedGreen, Ruby on Rails, RSpec) have an issue trying to play nicely together.
RedGreen actually will cause Autotest to crash when one of the following happens
- You save your code with a compile error (eg. missing ‘end’ tag)
- You add new spec files
The error looks like this:
/Library/Ruby/Gems/1.8/gems/ZenTest-3.6.1/lib/autotest/redgreen.rb:8: undefined method `match' for nil:NilClass (NoMethodError)
and will follow the compile error from your code, then stop autotest.
I posted a comment for the original author, Pat Eyler, and the comment was manually approved, but I haven’t received any actual response to know whether or not it will be updated. Just in case it won’t be, I hope this simple fix is useful for you.
To fix this problem, open up your
/Library/Ruby/Gems/1.8/gems/ZenTest-3.6.1/lib/autotest/redgreen.rb
file and change line 8 from:
if at.results.last.match(/^.* (\d+) failures, (\d+) errors$/)
to
if at.results.last && at.results.last.match(/^.* (\d+) failures, (\d+) errors$/)
Very simple, and it does the trick!
3 comments ↓
Hey there, I saw your comment about RedGreen, but I don’t maintain the code anymore. A couple of people have picked it up and been running with it.
I tried your patch, but, although it avoided the crash, it resulted in a loop … autotest re-runs all test immediately after last run instead of waiting for modifications.
Kepé, I’ve run into that issue a few times as well. I’m not entirely convinced yet that it’s a related issue. I haven’t had it happen to me in quite a while, and I’ve spoken to a number of people who haven’t used my patch but have also had this issue. I haven’t met anyone yet who knows how to fix it or what exactly causes it.
I do know I’ve managed to reproduce it by turning on –format progress and ALSO –format html. Individually they don’t cause my autotest to loop, but using them both at the time time causes my autotest to loop all the time.
However for the rare cases where I’ve experienced your bug, I haven’t been able to make it happen consistently.