[rspec-users] autospec runs failing specs forever in endless loop

Jarmo Pertman Jarmo.P at gmail.com
Mon Jun 1 17:10:55 EDT 2009

No, I didn't have that one, but had one similar problem where one of
my specs edited one non-Ruby file, which caused autotest to reload. I
solved that problem by explicitly ignoring it in autotest. I was
surprised that autotest cares about non-mapped files :)

But now I have another problem - it seems that autotest doesn't
understand always when something really failed and it seems to be due
to the fact that autotest.rb has this line:
self.failed_results_re = /^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)

It doesn't match correctly with most of the failing specs so Snarl
(like Growl for Windows) shows that tests are passing when they're
actually not. So, I digged around a little more to see if RSpec
modifies this regular expression somewhere and I found it at lib/
autotest/rspec.rb and there is this class Autotest::Rspec < Autotest,
which overwrites failed_results_re as: self.failed_results_re = /^\d+\)
\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n

This autotest thing seems to be quite strange, because if I added some
puts statements into discover.rb and rspec.rb then they didn't seem to
get executed, BUT if I putsed this failed_results_re in autotest.rb
itself, then it was set correctly as written above.

My .autotest file is as following:
require 'autotest/menu'
require 'autotest/snarl'

Autotest.add_hook :initialize do |at|

And spec.opts is like this:
-r spec/env.rb

And I'm running autospec and seeing this output:
'correct year' FAILED

expected "2008"
     got "2009"

(compared using eql?)


Finished in 5.918 seconds

11 examples, 1 failure

And when I added to autotest.rb line 410 this: p self.files_to_test
Then the resulted hash was empty, e.g. this line sets result to
"green": color = completed &&
self.files_to_test.empty? ? :green : :red

When I break some other test with different error message like this,
then Snarl shows me failing tests:
NoMethodError in 'DatabaseOperations adds options'
undefined method `[]' for nil:NilClass

The difference is that failing reason is shown on one line, instead of
two lines. Also, p elf.files_to_test results in "normal" result:
{"spec/database_operations_spec.rb"=>["DatabaseOperations adds
options", "DatabaseOperations adds new default_options if some are

- Is it possible that this regular expression is little outdated and
can't handle the situation where failing reason is shown on 2 lines?
- Why won't anything puts'ed from autotest/discover.rb or autotest/
rspec.rb like they aren't loaded?
- Any other reasons why autotest behaviour might be broken?


On Jun 1, 12:56 am, David Chelimsky <dchelim... at gmail.com> wrote:
> On Sun, May 31, 2009 at 3:59 PM, Jarmo Pertman <Jarm... at gmail.com> wrote:
> > I wanted to start using autospec on my little (non-Rails) project. I'm
> > on Windows XP and have used it some time ago successfully (on the same
> > PC), although I've updated many gems in the meantime (RSpec for
> > example among others).
> > In short, everything is fine when all specs pass, but if some fails,
> > then autospec won't stop running failing specs again even if no files
> > are changed. I expect it to run specs again only if some file gets
> > modified. It's kinda irritating when it doesn't stop and is by no
> > means helping any development :/
> > Also, when I fix the failing spec then it will run it only once and
> > then run whole suit once and stops as expected.
> > Any ideas what might cause this distracting behaviour?
> Do you have "--format failing_examples" in spec/spec.opts? If so,
> rspec saves a file with a list of the failing examples in it, which
> would trigger autotest to run again unless that file is explicitly
> ignored.
> HTH,
> David
> > BR,
> > Jarmo
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list