Remove warning about ansicon from “rake cucumber”

2019-06-23 23:04发布

When you run any rake task with cucumber installed on a machine that doesn't have ANSICON installed, you get the following message:

*** WARNING: You must use ANSICON 1.31 or higher (http://adoxa.110mb.com/ansicon) to get coloured output on Windows

When running locally I like using ANSICON, but when used within the build server I don't care about that - and I don't want to see that warning there. Is there a way to get rid of it?

3条回答
男人必须洒脱
2楼-- · 2019-06-23 23:25
  1. Download and unzip the file from http://adoxa.altervista.org/ansicon/
  2. open cmd and navigate to the unzipped folder
  3. Navigate to x64 (if you have a 64 bit machine) otherwise navigate to x86
  4. Type ansicon.exe -h and you will get help of this command
  5. Execute 'ansicon.exe -i' to install and add ansicon to your Windows
  6. Run your cucumber 0.10.0 test and you should get the coloured output result on Windows
查看更多
Summer. ? 凉城
3楼-- · 2019-06-23 23:30

Can you add an exception to you spec_helper.rb? Or perhaps try adding a tag which you filter on when using rake?

查看更多
神经病院院长
4楼-- · 2019-06-23 23:40

You can actually remove the warning itself. I do not like installing a bunch of garbage just for the sake of having a green word. So, to remove the warning:

1. Locate the Cucumber installation in gems directory (it's in the Ruby installation directory). For me it was: lib\ruby\gems\1.9.1\gems\cucumber-1.2.0

2. In the cucumber-1.2.0\lib\cucumber\formatter directory of the Cucumber installation find the file ansicolor.rb

3. Locate the line:

STDERR.puts %{*** WARNING: You must use ANSICON 1.31 or higher (http://adoxa.110mb.com/ansicon) to get coloured output on Windows}

and add # in front of it to comment it out:

# STDERR.puts %{*** WARNING: You must use ANSICON 1.31 or higher (http://adoxa.110mb.com/ansicon) to get coloured output on Windows}

The line number was 14 for my version of Cucumber.

4. Save the file and you're done

查看更多
登录 后发表回答