On Mar 10, 3:40=A0pm, Gordon Thiesfeld <gthiesf... / gmail.com> wrote:
> On Wed, Mar 10, 2010 at 2:35 AM, Luis Lavena <luislav... / gmail.com> wrote=
:
> > =3D=3D=3D=3D
>
> > Stops there, all without colors.
>
> > Now, running rake spec or spec -c spec display all colors too, so is
> > something around autospec/autotest and Ruby 1.9
>
> > =3D=3D=3D=3D
>
> > Hope I explained better this time since seems nobody answered on RSpec-
> > dev maybe my english wasn't good enough.
>
> Ah! I see the problem now. =A0I'm afraid it is in win32console[1], and
> I'm afraid I wrote it.
> This code will reproduce the bug:
>
> ruby -e "require 'rubygems'; require 'win32console'; %Q{\e[31mred\e[0m
> \e[32mgreen\e[0m}.each_byte{|i| putc
> i }"
>
> ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
> red green
> =A0# in color
>
> ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
> red green
> =A0# in color
>
> ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
> =A0[31mred [0m =A0[32mgreen [0m
>
> Autotest uses getc to read from stdout, and putc to write to it. =A0I
> redefined Kernel#putc to cache escape codes and write them all at
> once. =A0Otherwise, win32console won't work. =A0The problem in 1.9 is tha=
t
> "?\e" doesn't return the byte value, but the string. =A0I'll submit a
> patch.
>
> [1]http://github.com/luislavena/win32console/blob/master/lib/Win32/Conso.=
..
>

Gordon, your patch fix the issue with red/green sample, but still
generates ANSI codes when running under 1.9.1 with autospec.

I just cleared all the previous versions of win32console due buggy
load path of 1.9 and still see the same issue.

The positive side is that the specs now completes instead of
prematurely terminate itself.

Adding this to either project .autospec file or ~/.autospec file:

%Q{\e[31mred\e[0m \e[32mgreen\e[0m}.each_byte{|i| putc i }

Produces colored output, while adding to spec_helper.rb or any of the
files being evaluated inside autospec returns ANSI color codes.

--
Luis Lavena