Remove warning about ansicon from “rake cucumber”

烂漫一生 提交于 2019-12-23 12:45:57

问题


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?


回答1:


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




回答2:


  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



回答3:


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



来源:https://stackoverflow.com/questions/7019013/remove-warning-about-ansicon-from-rake-cucumber

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!