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

前端 未结 8 3169
迷失自我
迷失自我 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 04:05

    When using the MINGW64 bash shell provided by Git on Windows rspec displays things without any color. While this shell environment is perfectly capable of displaying ANSI color, rspec fails to detect it as a TTY. A super simple workaround is to use:

    $ rspec --force-color
    

    For example, take this boring old monochrome: :

    And make it happy with one simple command line argument:

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

    Did you specify '--color' in your rake rspec tasks' spec_opts? Something like this..

      Spec::Rake::SpecTask.new(:your_task_name) do |t|
        t.spec_opts = ["--color"]
        t.spec_files = [] # List of spec files
      end
    
    0 讨论(0)
提交回复
热议问题