class Spinach::Reporter::Progress

The Progress reporter outputs the runner results to the standard output

Public Class Methods

new(*args) click to toggle source

Initializes the reporter

@param [Hash] options

Sets a custom output buffer by setting options[:output]
Sets a custom error buffer by setting options[:error]
Calls superclass method Spinach::Reporter::new
# File lib/spinach/reporter/progress.rb, line 17
def initialize(*args)
  super(*args)
  @out = options[:output] || $stdout
  @error = options[:error] || $stderr
end

Public Instance Methods

on_error_step(step, failure, step_location, step_definitions = nil) click to toggle source

Adds a step that has raised an error to the output buffer.

@param [Hash] step

The step in a JSON GherkinRuby format

@param [Exception] failure

The exception that caused the failure
# File lib/spinach/reporter/progress.rb, line 59
def on_error_step(step, failure, step_location, step_definitions = nil)
  output_step('E', :red)
  self.scenario_error = [current_feature, current_scenario, step, failure]
  error_steps << scenario_error
end
on_failed_step(step, failure, step_location, step_definitions = nil) click to toggle source

Adds a failing step to the output buffer.

@param [Hash] step

The step in a JSON GherkinRuby format

@param [Exception] failure

The exception that caused the failure
# File lib/spinach/reporter/progress.rb, line 45
def on_failed_step(step, failure, step_location, step_definitions = nil)
  output_step('F', :red)
  self.scenario_error = [current_feature, current_scenario, step, failure]
  failed_steps << scenario_error
end
on_pending_step(step, failure) click to toggle source

Adds an undefined step to the output buffer.

@param [Hash] step

The step in a JSON GherkinRuby format
# File lib/spinach/reporter/progress.rb, line 81
def on_pending_step(step, failure)
  output_step('P', :yellow)
  self.scenario_error = [current_feature, current_scenario, step, failure]
  pending_steps << scenario_error
end
on_skipped_step(step, step_definitions = nil) click to toggle source

Adds a step that has been skipped to the output buffer.

@param [Hash] step

The step that GherkinRuby extracts
# File lib/spinach/reporter/progress.rb, line 92
def on_skipped_step(step, step_definitions = nil)
  output_step('~', :cyan)
end
on_successful_step(step, step_location, step_definitions = nil) click to toggle source

Adds a passed step to the output buffer.

@param [Step] step

The step.

@param [Array] step_location

The step source location
# File lib/spinach/reporter/progress.rb, line 31
def on_successful_step(step, step_location, step_definitions = nil)
  output_step('.', :green)
  self.scenario = [current_feature, current_scenario, step]
  successful_steps << scenario
end
on_undefined_step(step, failure, step_definitions = nil) click to toggle source

Adds an undefined step to the output buffer.

@param [Hash] step

The step in a JSON GherkinRuby format
# File lib/spinach/reporter/progress.rb, line 70
def on_undefined_step(step, failure, step_definitions = nil)
  output_step('U', :yellow)
  self.scenario_error = [current_feature, current_scenario, step, failure]
  undefined_steps << scenario_error
end
output_step(text, color = :grey) click to toggle source

Adds to the output buffer a step result

@param [String] text

A symbol to prepend before the step keyword (might be useful to
indicate if everything went ok or not).

@param [Symbol] color

The color code to use with Colorize to colorize the output.
# File lib/spinach/reporter/progress.rb, line 105
def output_step(text, color = :grey)
  out.print(text.to_s.colorize(color))
end