module Cucumber::Formatter::ANSIColor

This module allows to format cucumber related outputs using ANSI escape sequences.

For example, it provides a ‘passed` method which returns the string with the ANSI escape sequence to format it green per default.

To use this, include or extend it in your class.

Example:

require 'cucumber/formatter/ansicolor'

class MyFormatter
  extend Cucumber::Term::ANSIColor

  def on_test_step_finished(event)
    $stdout.puts undefined(event.test_step) if event.result.undefined?
    $stdout.puts passed(event.test_step) if event.result.passed?
  end
end

This module also allows the user to customize the format of cucumber outputs using environment variables.

For instance, if your shell has a black background and a green font (like the “Homebrew” settings for OS X’ Terminal.app), you may want to override passed steps to be white instead of green.

Example:

export CUCUMBER_COLORS="passed=white,bold:passed_param=white,bold,underline"

The colours that you can change are:

To see what colours and effects are available, just run this in your shell:

ruby -e "require 'rubygems'; require 'cucumber/term/ansicolor'; puts Cucumber::Term::ANSIColor.attributes"