Method: RSpec::Core::Configuration#color_enabled?

Defined in:
lib/rspec/core/configuration.rb

#color_enabled?(output = output_stream) ⇒ Boolean

Check if color is enabled for a particular output.

Parameters:

  • output (IO) (defaults to: output_stream)

    an output stream to use, defaults to the current output_stream

Returns:

  • (Boolean)


943
944
945
946
947
948
949
950
# File 'lib/rspec/core/configuration.rb', line 943

def color_enabled?(output=output_stream)
  case color_mode
  when :on then true
  when :off then false
  else # automatic
    output_to_tty?(output) || (color && tty?)
  end
end