RSpec: "--color" not working in spec.opts when combined with

Windows XP SP 2
ruby 1.8.5

gems:
rails 1.2.3
rake 0.7.3
win32console 1.0.8

plugins:
rspec 1.0.8
rspec_rails 1.0.8

spec.opts:
–colour
–format
progress
–loadby
mtime
–reverse
–drb

When I run “rake spec” or “ruby script/spec spec --color” this is the
output:

D:\dev\project>rake spec
(in D:/dev/project)
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m

Finished in 0.172 seconds

←[32m11 examples, 0 failures←[0m

If I remove “–drb” from the spec.opts file it runs fine (but slower).

I’m having the same problem. Also, “rake spec” doesn’t connect to my
running spec_server, but “ruby script/spec spec/models --drb” does. Do
you have that this problem too?

I’m running:
Vista
ruby 1.8.6
rails 1.2.3
rake 0.7.3
win32console 1.0.8
rspec 1.0.8.
same spec.opts

I’m not having an issue with “rake spec” not connecting to
spec_sever.

Could it be an issue with Vista?

Ok disregard the rake spec not connecting to spec_server thing - I
wasn’t using it properly.

I found a workaround to get colour and drb working together:

Add “require ‘Win32/Console/ANSI’” before the last line in your spec
file and change the STDOUT parameter in the last line to $stdout.

So /script/spec should look like this:

#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(FILE) + “/…/
vendor/plugins/rspec/lib”))
require ‘spec’
require ‘Win32/Console/ANSI’
::Spec::runner::CommandLine.run(ARGV, STDERR, $stdout, true, true)

It’s not perfect. The first run will print the output to the console
that spec_server is running in. All subsequent runs will print to the
correct console though. I couldn’t figure out why it was doing this
but the way it works is good enough for me.

It worked perfectly! Thank you Rich.

I haven’t tried autotest yet but I’d like to - it sounds awesome. I’ll
try it tonight and see if I get any output. I also posted that
workaround as a comment to the bug in rspec’s tracker. Hopefully
they’ll fix it properly soon.

I did notice that this fix will suppress any output when using
autotest.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs