Class: Specifier::Formatter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/specifier/formatter/base.rb

Overview

A base defintion for formatting the specifier results.

Usage:

formatter = Specifier::Formatter::Base.new
formatter.record(example, result)
formatter.summarize

Direct Known Subclasses

Documentation, Progress

Defined Under Namespace

Classes: Recording

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Base

Returns a new instance of Base.



27
28
29
30
31
# File 'lib/specifier/formatter/base.rb', line 27

def initialize(logger)
  @logger = logger
  @recordings = []
  @contexts = []
end

Instance Method Details

#context(context) ⇒ Object



37
38
39
40
# File 'lib/specifier/formatter/base.rb', line 37

def context(context)
  @contexts << context
  yield
end

#record(example, result) ⇒ Object



33
34
35
# File 'lib/specifier/formatter/base.rb', line 33

def record(example, result)
  @recordings << Recording.new(example, result)
end

#summarizeObject



42
43
44
45
# File 'lib/specifier/formatter/base.rb', line 42

def summarize
  @logger.log
  @logger.log(summary)
end