Class: RSpec::CapturingFormatter::Renderer::FailureColorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/capturing_formatter/renderer.rb

Overview

Adapts the formatter's color policy to RSpec's failure-presenter interface.

Instance Method Summary collapse

Constructor Details

#initialize(renderer) ⇒ FailureColorizer

Returns a new instance of FailureColorizer.



429
430
431
# File 'lib/rspec/capturing_formatter/renderer.rb', line 429

def initialize(renderer)
  @renderer = renderer
end

Instance Method Details

#wrap(text, color) ⇒ Object



433
434
435
436
437
438
# File 'lib/rspec/capturing_formatter/renderer.rb', line 433

def wrap(text, color)
  return text unless @renderer.formatter_color_enabled?

  code = COLORS[color]
  code ? "#{code}#{text}#{RESET}" : text
end