Class: XSpec::Notifier::ColoredDocumentation

Inherits:
Object
  • Object
show all
Includes:
Composable, EmptyFormatter, ShortIdSupport
Defined in:
lib/xspec/notifiers.rb

Overview

Includes nicely formatted names and durations of each test in the output, with color.

Direct Known Subclasses

Documentation

Constant Summary collapse

VT100_COLORS =
{
  :black   => 30,
  :red     => 31,
  :green   => 32,
  :yellow  => 33,
  :blue    => 34,
  :magenta => 35,
  :cyan    => 36,
  :white   => 37
}

Instance Method Summary collapse

Methods included from ShortIdSupport

#run_start, #short_id_for

Methods included from Composable

#+

Methods included from EmptyFormatter

#evaluate_start, #run_start

Constructor Details

#initialize(out = $stdout) ⇒ ColoredDocumentation

Returns a new instance of ColoredDocumentation.



235
236
237
238
239
240
# File 'lib/xspec/notifiers.rb', line 235

def initialize(out = $stdout)
  self.indent          = 2
  self.last_seen_names = []
  self.failed          = false
  self.out             = out
end

Instance Method Details

#evaluate_finish(result) ⇒ Object



242
243
244
245
246
247
248
249
250
# File 'lib/xspec/notifiers.rb', line 242

def evaluate_finish(result)
  output_context_header! result.parents.map(&:name).compact

  spaces = ' ' * (last_seen_names.size * indent)

  self.failed ||= result.errors.any?

  out.puts "%s%s" % [spaces, decorate(result)]
end

#run_finishObject



252
253
254
255
# File 'lib/xspec/notifiers.rb', line 252

def run_finish
  out.puts
  !failed
end