Entries Tagged 'redgreen' ↓

Autotest crashes using RedGreen

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!