Question

If I create a new Rails (3.2.12) app. Add the test-unit gem to my development, test group, and then scaffolded resource. When I run the tests from the Mac console.app, I get color output.

bundle exec rake test

When I create a tmux session (in console.app) for the app and run the exact same command. I don't get color output. However if I pass the "--use-color" switch, then I do get color output for the tests in tmux.

bundle exec rake test TESTOPTS="--use-color"

I'm setting 256 colors in my tmux.config with set -g default-terminal "screen-256color". Any idea why I don't get color in tmux when I run the rake task without the TESTOPTS?

Was it helpful?

Solution

It appears that test-unit guesses whether the terminal supports color by (mainly) looking at the TERM environment variable. Unfortunately, screen-256color does not satisfy the checks that it makes.

It might be reasonable to ask that its recognition of screen be extended to include screen-256color, also.

I think you can drop some entries in a configuration file to supply default arguments. The first of test-unit.yml (in the current directory) or ~/.test-unit.yml (a “hidden” file in your home directory) will be loaded:

runner: console
console_options:
  arguments: --use-color=yes
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top