Module: RSpec::Core::Formatters::ConsoleCodes

Defined in:
opal/opal/rspec/fixes/rspec/core/formatters/console_codes.rb

Instance Method Summary collapse

Instance Method Details

#wrap(text, code_or_symbol) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'opal/opal/rspec/fixes/rspec/core/formatters/console_codes.rb', line 2

def wrap(text, code_or_symbol)
  if RSpec.configuration.color_enabled?
    # Need to escape the \e differently in JS and can't use string interpolation
    #"\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m"
    "\033" + "[#{console_code_for(code_or_symbol)}m#{text}" +"\033" + '[0m'
  else
    text
  end
end