class RSpecSystem::Formatter

This custom formatter is designed for rspec-system test presentation

Because rspec-system tests are often wordier and require lots of diagnostic information to be enabled for future debugging, the traditional document and progress formatters just simply aren’t sufficient.

This formatter instead treats each test as a document section, splitting up the output with obvious breaks so the user can clearly see when a test has started and finished. It also attempts to use color for visibility as well as listing test case information in a more verbose way.

Public Class Methods

new(output) click to toggle source

Initialize formatter

Calls superclass method
# File lib/rspec-system/formatter.rb, line 16
def initialize(output)
  super(output)
end

Public Instance Methods

example_failed(example) click to toggle source

Display output when an example has failed

@param example [RSpec::Core::Example] example that is running @return [void]

Calls superclass method
# File lib/rspec-system/formatter.rb, line 69
def example_failed(example)
  super(example)
  msg = example.execution_result[:exception]
  output << "\n" << bold('Result: ') << failure_color('failed') << "\n"
  output << bold("Reason:\n") << "#{msg}\n\n"
  output << "=end=============================================================\n\n"
end
example_passed(example) click to toggle source

Display output when an example has passed

@param example [RSpec::Core::Example] example that is running @return [void]

Calls superclass method
# File lib/rspec-system/formatter.rb, line 47
def example_passed(example)
  super(example)
  output << "\n" << bold('Result: ') << success_color('passed') << "\n\n"
  output << "=end=============================================================\n\n"
end
example_pending(example) click to toggle source

Display output when an example is pending

@param example [RSpec::Core::Example] example that is running @return [void]

Calls superclass method
# File lib/rspec-system/formatter.rb, line 57
def example_pending(example)
  super(example)
  msg = example.execution_result[:pending_message]
  output << "\n" << bold('Result: ') << pending_color('pending') << "\n"
  output << bold("Reason: ") << "#{msg}\n\n"
  output << "=end=============================================================\n\n"
end
example_started(example) click to toggle source

Display output when an example has started

@param example [RSpec::Core::Example] example that is running @return [void]

Calls superclass method
# File lib/rspec-system/formatter.rb, line 36
def example_started(example)
  super(example)
  output << "\n=begin===========================================================\n\n"
  output << bold("Running test: ") << "#{next_index} of #{@max_tests}" << "\n"
  output << bold("Description:\n  ") << color(example.full_description, :magenta) << "\n\n"
end
next_index() click to toggle source

Obtains next index value so we can keep a count of what test we are upto

@api private @return [Fixnum] index #

# File lib/rspec-system/formatter.rb, line 81
def next_index
  @next_index ||= 0
  @next_index += 1
end
start(count) click to toggle source

Display test start information

@param count [Fixnum] number of tests to run @return [void]

Calls superclass method
# File lib/rspec-system/formatter.rb, line 24
def start(count)
  @max_tests = count
  super(count)
  output << "\n"
  output << bold("Commencing rspec-system tests\n")
  output << bold("Total Test Count: ") << color(count, :cyan) << "\n\n"
end