RSpec Git Bash Windows - Missing Color?

I use Git Bash for Windows for most of my work with Rails, and every time I run bundle exec rspec spec , it warns me "You must gem install win32console use color on Windows" and then run RSpec in normal black and white. However, I installed win32console, and when I ran the gem list in the list, it has win32console (1.3.0 x86-mingw32) . RSpec works fine, but I would like it to have some kind of color. I searched this Google and found some solutions, but no one works for me. Can someone please write a “step by step” approach to getting color from RSpec in Git Bash for Windows?

+6
source share
4 answers

This blog is very good, showing how to make ansicon. http://thehumblecto.blogspot.com/2012/06/rspec-color-output-in-windows.html

+4
source

I am not familiar with Git Bash for Windows, but if it uses a standard Windows console, you can try it with ANSICON .

You should visit the ANSICON homepage to find out about the latest version and download location.

It comes in the form of a ZIP package containing sources and binaries. Installation instructions are in readme.txt .

Older downloads are still available on Github: https://github.com/adoxa/ansicon/downloads

Blog entries containing ANSICON documentation with screenshots:

+3
source

Following @ dallma77's post, using ansicon seems to allow RSpec to output color to the Windows cmd command prompt!

Now I can get color information from RSpec without copying the dll file (and probably without running 'ansicon -i' or 'ansicon -I'). Include the PATH entry pointing to the x64 folder (for example, C: \ Users \ yourusername \ pathtofolder \ ansi150 \ x64) or the x86 folder where you extracted the ansicon zip file (here I downloaded the zip file http: //adoxa.3eeweb .com / ansicon / index.html ).

But the trick seems to be that RSpec should start from the root of the application, otherwise I don't see the output color.

I follow Michael Hartl’s (excellent) Ruby On Rails Tutorial (http://ruby.railstutorial.org/), and sample_app is my application root, so I see green and red with for example C: \ Sites \ rails_projects \ sample_app> bundle exec rspec spec \ requests \ static_pages_spec.rb but only monochrome output with e.g. C: \ Sites \ rails_projects \ sample_app \ spec \ requests> bundle exec rspec static_pages_spec.rb

+2
source

Since this, it would seem, did not answer ... Seeing this, I changed my mind to reconsider this problem on my Win7 machine. I also couldn’t get the colors to work, but since at that time I still had to worry (I was RR nweb (still, I think), and Rspec worked in b / w), so I went over, Seeing @Zetetic's answer, reminded me that I downloaded ANSICON but did not connect the dots to it. So, I tried the following. I just copied ansi32.dll and ansicon.exe from the x86 folder of ansi140 (extracted from ansi140.zip) to the root folder of the application. Having opened the cmd window with Ruby and Rails and point to my application root and run ansicon.exe, run my test, and I see green (and red).

I see that some time has passed, so I hope this helps someone. I just got active here last week.

By the way, I do not have win32console in my jewelry list, but I have a win32 service 0.7.2 (not related, I think) and some other win32-gems. Do not remember how and why they are needed, but here is the list: win32-api 1.4.8, win32-open3 0.3.2, windows-api 0.4.1, windows-pr 1.2.1.

Most likely, they are the gems of dependencies for the win32 service or other things that the picker turned on automatically for me. The wonderful thing is the bunch. I think, however, the win32 service is for mongrel-service (which I could not get, but this is another problem).

+1
source

Source: https://habr.com/ru/post/890357/


All Articles