How do I get colour with Windows command prompt using RSpec in Ruby?

前端 未结 8 3002
迷失自我
迷失自我 2021-02-20 03:10

In other o/s RSpec returns nicely coloured results (red, green etc).

However in the windows (Vista) command prompt my text output is just plain old boring white.

相关标签:
8条回答
  • 2021-02-20 03:44

    You need to install the win32console gem. BTW: which version of RSpec are you using? Every single version of RSpec I have ever used, actually prints out

    You must 'gem install win32console' to use colour on Windows
    

    when you try to colorize output.

    0 讨论(0)
  • 2021-02-20 03:51

    The best method is to create a file name .rspec in the root folder of your app and include this single line of code in it:

    --colour

    Done and dusted

    0 讨论(0)
  • 2021-02-20 03:56

    UPDATE: Win32Console no longer works with rspec. ANSICON recommended. https://github.com/rspec/rspec-rails/issues/487#issuecomment-3556806

    0 讨论(0)
  • 2021-02-20 04:00

    I had to install ansicon, and now everything is fine. (Even in my Aptana terminal).

    Install ansicon description: http://qastuffs.blogspot.com/2011/02/how-to-install-ansicon-for-cucumber-to.html

    0 讨论(0)
  • 2021-02-20 04:03

    I had this issue. I've been unable to get ansicon to work, as it crashes when running from cmd.

    To fix I added the Win32console gem to my gem file and then ran bundle update.

    **As an update: Put the gem in the test group of your gemfile:

        group :test do
          gem 'rails-controller-testing', '1.0.2'
          gem 'minitest-reporters',       '1.1.14'
          gem 'guard',                    '2.13.0'
          gem 'guard-minitest',           '2.4.4'
          gem 'win32console'
        end
    

    This will prevent errors when pushing to heroku

    Cheers!

    0 讨论(0)
  • 2021-02-20 04:05

    I'm running in Windows XP which I believe is an NT system. The ANSICON claims that this is not supported. Yes it does not work for cmd. But if you put the files in system32 folder, just run the ansicon.exe from anywhere. Win32Console is deprecated for rspec but you may still use it for other programs you write if you want color output from the command line. see the readmes in the gem. I put ansicon in my start>run>open text box. It works just fine.

    0 讨论(0)
提交回复
热议问题