Skip to content

Commit

Permalink
Only check for color once
Browse files Browse the repository at this point in the history
  • Loading branch information
rf- committed Sep 9, 2012
1 parent f4b7ddf commit 0e22139
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions test/helper.rb
Expand Up @@ -11,14 +11,10 @@
# Colorize output (based on greeneggs (c) 2009 Michael Fleet) # Colorize output (based on greeneggs (c) 2009 Michael Fleet)
# TODO: Make own gem (assigned to rking) # TODO: Make own gem (assigned to rking)
module Bacon module Bacon
COLORS = {'F' => 31, 'E' => 35, 'M' => 33, '.' => 32} COLORS = {'F' => 31, 'E' => 35, 'M' => 33, '.' => 32}
USE_COLOR = Pry::Helpers::BaseHelpers.use_ansi_codes?


module TestUnitOutput module TestUnitOutput
def handle_specification(name)
@use_color = Pry::Helpers::BaseHelpers.use_ansi_codes?
yield
end

def handle_requirement(description) def handle_requirement(description)
error = yield error = yield


Expand All @@ -44,7 +40,7 @@ def handle_summary
end end


def colorize_string(text, color = nil) def colorize_string(text, color = nil)
if @use_color if USE_COLOR
"\e[#{ COLORS[color || text] }m#{ text }\e[0m" "\e[#{ COLORS[color || text] }m#{ text }\e[0m"
else else
text text
Expand Down

0 comments on commit 0e22139

Please sign in to comment.