-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colorize the results #27
Comments
By googling "ruby puts with colors" I found this link. It might be a good starting point: |
This was brought up by the rspec plugin, but you can see the same lack of color by doing: This line runs the supplied system program: There are a surprising number of ways to start these system programs in ruby. Unfortunately, I can't find one that returns the output and prints the results in color for commands like rspec and git status. |
@rossfuhrman Can you try running the following script? # the_test.rb
require 'minitest/autorun'
require 'minitest/spec'
require 'minitest/pride'
(1..1000).each { |_| describe("x") { it("x") { 1.must_equal 1 } } } |
Right. If I use the minitest pride plugin, I get colors. It looks like the pride plugin re-writes the output so that it is encoded with the colors. A "." becomes But the colors are lost when running system commands through the starting blocks execute command line option as well. |
@rossfuhrman I know nothing about how those terminal colors work. Have you looked through these options? http://stackoverflow.com/questions/2232/calling-shell-commands-from-ruby |
I'm wondering... maybe there's a gem that would give us both? |
I looked at that link as well as some of the links inside of it. There are a bunch of ways to run system commands from within ruby, but I couldn't get any of them to do all of these at the same time: I think I will try to create a simplified version of the program that just demonstrates the problem and some of the solutions I've tried so we can try and figure something out. |
If we can figure it out, we might also consider creating a gem to solve the problem for others. I say this because I haven't been able to find a gem to do what we need yet. |
I created a gist to demonstrate different ways to run system commands through ruby. However none of them meet the criteria to fix this bug. |
@rossfuhrman Hmm... perhaps we could run the tests twice? 👅 |
@rossfuhrman Thinking aloud.... perhaps starting blocks could expose the method to be changed per plugin. So let's say you're using rspec. If the rspec plugin parsed the text results and not the response code, then perhaps that plugin could switch the system to show the proper colors. But if another plugin needs the response, then it can switch to that mode too. |
@darrencauthon Yeah, like passing a color option to the call to sb? |
@rossfuhrman Yeah, you are right... it's hard to tell how these plugins will play together with this option getting flipped. We should bring this up in tonight's KC Ruby meetup. |
Today, output from the script is printed out with a simple
puts
command.If that output includes text with colors, the colors will not be shown... the color codes will be shown instead.
Is there a way to print out the colors?
This issue was brought up with the starting_blocks-rspec issue here rossfuhrman/starting_blocks-rspec#4
The text was updated successfully, but these errors were encountered: