class Specifier::Formatter::Documentation

A custom defintion for formatting the specifier results.

Usage:

formatter = Specifier::Formatter::Documentation.new
formatter.context(context) do
  formatter.record(example, result)
end
formatter.summarize

Constants

FAIL
INDENTATION
NAME
PASS

Public Class Methods

new(logger) click to toggle source
Calls superclass method Specifier::Formatter::Base::new
# File lib/specifier/formatter/documentation.rb, line 22
def initialize(logger)
  super
  @indentation = 0
end

Public Instance Methods

context(context) click to toggle source
Calls superclass method Specifier::Formatter::Base#context
# File lib/specifier/formatter/documentation.rb, line 39
def context(context)
  @logger.log(indent(context.description))

  @indentation = @indentation.next
  super
  @indentation = @indentation.pred
end
record(example, result) click to toggle source
Calls superclass method Specifier::Formatter::Base#record
# File lib/specifier/formatter/documentation.rb, line 27
def record(example, result)
  super

  message =
    case result.status
    when :pass then Colorizer.passed(indent("#{PASS} #{example.description}"))
    when :fail then Colorizer.failed(indent("#{FAIL} #{example.description}"))
    end

  @logger.log(message)
end

Private Instance Methods

indent(message) click to toggle source
# File lib/specifier/formatter/documentation.rb, line 49
def indent(message)
  INDENTATION * @indentation + String(message)
end