[rspec-users] rspec_autotest no longer re-runs tests with rspec 0.7.5
Nick Sieger
nicksieger at gmail.com
Tue Jan 2 11:03:52 EST 2007
On 1/1/07, Michael Johnston <lastobelus at mac.com> wrote:
>
> Ok I just took the time to figure this out. It should have been obvious to
> me: turning on redgreen breaks the regex in "handle_results" which should
> create an array of failed tests because the color codes that are added to
> the result string.
> I discovered it was also mildly broken without color, because the second
> term in the regex needs to be made non greedy, or it matches everything
> after the first error. But because of the way this is used, I don't think
> this would make much (any) difference to the functioning of autotest.
>
> Anyway, so here is the diff with the regex for handle_results function of
> rspec_autotest that works with redgreen turned on (and with spec command
> changed to use the rails_spec_server):
>
> Index: lib/rspec_autotest.rb
> ===================================================================
> --- lib/rspec_autotest.rb (revision 45)
> +++ lib/rspec_autotest.rb (working copy)
> @@ -26,7 +26,7 @@
> attr_accessor :spec_command
> def initialize # :nodoc:
> - @spec_command = "spec --diff unified"
> + @spec_command = "script/rails_spec -C --diff unified"
> super
> @exceptions = %r%^\./(?:coverage|db|doc|log|public|script|vendor)%
> end
> @@ -76,7 +76,7 @@
> end
> def handle_results(results)
> - failed = results.scan(/^\d+\)\n(?:.*?Error in )?'([^']*?)'(?:
> FAILED)?\n(.*)\n\n/m)
> + failed = results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in
> )?'([^']*?)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
> @files_to_test = consolidate_failures failed
> unless @files_to_test.empty? then
> hook :red
>
Thanks Michael, I committed a slightly modified version of the regex. I
didn't commit the change to @spec_command because you can easily customize
this for yourself by putting a hook in your ~/.autotest:
Autotest.add_hook :initialize do |at|
if at.respond_to? :spec_command
at.spec_command = "script/rails_spec -C --diff unified"
end
end
Cheers,
/Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070102/1e08b634/attachment.html
More information about the rspec-users
mailing list