From: Luis Lavena Date: 2010-03-10T17:35:09+09:00 Subject: Re: win32console 1.3.0.beta2 Released On Mar 10, 5:34 am, Gordon Thiesfeld wrote: > On Tue, Mar 9, 2010 at 7:49 AM, Roger Pack wrote: > > >> No, is not win32console, I've emailed rspec team before on this: > > >>http://rubyforge.org/pipermail/rspec-devel/2010-January/005341.html > > > Thanks for the link. > > Appears it is a bug with spec since autospec doesn't show colors but > > normal "spec" does. > > > Thanks for your work on this. > > -rp > > -- > > Posted viahttp://www.ruby-forum.com/. > > If all of this code still works the way I remember it, this is > actually easy to fix. Last time I checked, autospec relies on > autotest, so you should be able to just require win32console in your > ~/.autotest file.   autospec runs the rspec framework as a subprocess. >  It parses the results, then spits them out on the screen.  On posix > systems, the escape codes work, because posix systems are designed to > handle them.  In Windows, the escape codes just get dumped to stdout, > so you have to make sure the current process knows how to handle them. > > I hope that makes sense. It does, however, as I mentioned in the RSpec-dev mailing list post, trying to recreate it just end prematurely, doesn't complete. Ignoring for a second that ZenTest/autospec changes the first two lines of the autotest rubygem stub, check the following example: #ruby ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32] #gem list: win32console (1.3.0.beta2, 1.3.0.beta1) rspec (1.3.0) ZenTest (4.2.1) # ~/.autotest STDOUT.puts "OUT: THIS IS ~/.autotest file" STDERR.puts "ERR: THIS IS ~/.autotest file" require 'win32console' puts "$stdout.redirected? #{$stdout.redirected?}" puts "$stderr.redirected? #{$stderr.redirected?}" # rake-compiler/.autotest STDOUT.puts "OUT: THIS IS rake-compiler/.autotest file" STDERR.puts "ERR: THIS IS rake-compiler/.autotest file" require 'win32console' puts "$stdout.redirected? #{$stdout.redirected?}" puts "$stderr.redirected? #{$stderr.redirected?}" Running autospec in my folder, output this: C:\Users\Luis\Projects\oss\rake-compiler>autospec (Not running features. To run features in autotest, set AUTOFEATURE=true.) loading autotest/rspec OUT: THIS IS ~/.autotest file ERR: THIS IS ~/.autotest file $stdout.redirected? false $stderr.redirected? false OUT: THIS IS rake-compiler/.autotest file ERR: THIS IS rake-compiler/.autotest file $stdout.redirected? false $stderr.redirected? false C:\Users\Luis\Tools\Ruby\ruby-1.8.6-p398-i386-mingw32\bin\ruby C:/ Users/Luis/.gem/ruby/x86-mingw32/1.8/gems/rspec-1.3.0/bin/spec -- autospec C:/Users/Luis/Projects/oss/rake-compiler/spec/lib/rake/ javaextensiontask_spec.rb C:/Users/Luis/Projects/oss/rake-compiler/ spec/lib/rake/extensiontask_spec.rb -O spec/spec.opts And from there beautiful colors (well, not beautiful, but seems it works). The following version also works: ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] But NOT 1.9.1: C:\Users\Luis\Projects\oss\rake-compiler>autospec loading autotest/rspec OUT: THIS IS ~/.autotest file ERR: THIS IS ~/.autotest file $stdout.redirected? false $stderr.redirected? false OUT: THIS IS rake-compiler/.autotest file ERR: THIS IS rake-compiler/.autotest file $stdout.redirected? false $stderr.redirected? false C:\Users\Luis\Tools\Ruby\ruby-1.9.1-p378-i386-mingw32\bin\ruby C:/ Users/Luis/.gem/ruby/x86-mingw32/1.9.1/gems/rspec-1.3.0/bin/spec -- autospec C:/Users/Luis/Projects/oss/rake-compiler/spec/lib/rake/ extensiontask_spec.rb C:/Users/Luis/Projects/oss/rake-compiler/spec/ lib/rake/javaextensiontask_spec.rb -O spec/spec.opts Rake::ExtensionTask #new (basic) WARNING: You're cross-compiling a binary extension for JRuby, but are using another interpreter. If your Java classpath or extension dir settings are not correctly detected, then either check the appropriate environment variables or execute the Rake compilation task using the JRuby interpreter. (e.g. `jruby -S rake compile:java`) ==== 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 ==== Hope I explained better this time since seems nobody answered on RSpec- dev maybe my english wasn't good enough. Regards, -- Luis Lavena