29

Developing with my first Mac and I noticed that my Rspec output isn't colorized in my terminal even though I'm using the '-c' flag in the command: bundle exec rspec -c -fd. Any ideas?

steve_gallagher
  • 3,778
  • 8
  • 33
  • 51

3 Answers3

57

Add the following contents to a .rspec file to your project dir root.

--color

Jens Tinfors
  • 880
  • 7
  • 6
15

If you're coming here from Google recently, you may notice that Allen Chun's answer gives a NoMethodError with .color_enabled when using RSpec 3.0 or higher. .color_enabled was removed in 3.0: https://github.com/rspec/rspec-core/blob/master/Changelog.md#300rc1--2014-05-18

Just change .color_enabled to .color in spec_helper.rb:

RSpec.configure do |config|
  # Use color in STDOUT
  config.color = true

  # other config options here...    

end

This worked for me with Ruby 2.1.2p95 on OS X Mavericks 10.9.4.

flanger001
  • 757
  • 6
  • 16
7

You can also put the config on the spec_helper.rb if you don't want to attach --color every time you run rspec.

RSpec.configure do |config|
 # Use color in STDOUT
   config.color_enabled = true

 # Use color not only in STDOUT but also in pagers and files
   config.tty = true

 # Use the specified formatter
   config.formatter = :documentation # :progress, :html, :textmate
end
AllenC
  • 2,754
  • 1
  • 41
  • 74