Class: Riot::StoryReporter

Inherits:
IOReporter show all
Defined in:
lib/riot/reporter/story.rb

Overview

For each context that is started and assertion that is run, its description is printed to the console on its own line. Regarding assertions, if ansi-colors are available then passing assertions are printed in green, failing in yellow, and errors in red. Note that backtraces are not reported for errors; see VerboseStoryReporter.

Direct Known Subclasses

VerboseStoryReporter

Instance Attribute Summary

Attributes inherited from Reporter

#current_context, #errors, #failures, #passes

Instance Method Summary collapse

Methods inherited from IOReporter

#filter_backtrace, #format_error, #green, #initialize, #line_info, #plain?, #print, #puts, #red, #results, #with_color, #yellow

Methods inherited from Reporter

#initialize, #new, #report, #results, #success?, #summarize

Constructor Details

This class inherits a constructor from Riot::IOReporter

Instance Method Details

#describe_context(context) ⇒ Object

Prints the descrition of the context on its own line

Parameters:

  • context (Riot::Context)

    the context that is about to execute



11
12
13
14
# File 'lib/riot/reporter/story.rb', line 11

def describe_context(context)
  super
  puts context.detailed_description
end

#error(description, e) ⇒ Object

Prints the description of the assertion and the exception message. Prints in red if possible.

Parameters:

  • description (String)

    the description of the assertion

  • ] (Array<Symbol, Exception])

    result the exception from the assertion



35
36
37
# File 'lib/riot/reporter/story.rb', line 35

def error(description, e)
  puts "  ! " + red("#{description}: #{e.message}")
end

#fail(description, message, line, file) ⇒ Object

Prints the description of the assertion and the line number of the failure. Prints in yellow if possible.

Parameters:

  • description (String)

    the description of the assertion

  • ] (Array<Symbol, String, Number, String])

    response the evaluation response from the assertion



27
28
29
# File 'lib/riot/reporter/story.rb', line 27

def fail(description, message, line, file)
  puts "  - " + yellow("#{description}: #{message} #{line_info(line, file)}".strip)
end

#pass(description, message) ⇒ Object

Prints the description of the assertion. Prints in green if possible.

Parameters:

  • description (String)

    the description of the assertion

  • ] (Array<Symbol, String])

    result the evaluation response from the assertion



19
20
21
# File 'lib/riot/reporter/story.rb', line 19

def pass(description, message)
  puts "  + " + green("#{description} #{message}".strip)
end