Class: Validator::Steps

Inherits:
FormatterBase show all
Defined in:
spec/support/formatters/steps.rb

Instance Method Summary collapse

Methods inherited from FormatterBase

#close, #colorize, #dump_failures, #dump_sentinel_summary, #dump_sentinel_warnings, #dump_summary, #example_group_finished, #example_group_started, #initialize

Constructor Details

This class inherits a constructor from Validator::FormatterBase

Instance Method Details

#dump_pending(notification) ⇒ Object



54
55
56
57
# File 'spec/support/formatters/steps.rb', line 54

def dump_pending notification
  dump_sentinel_warnings
  super notification
end

#example_failed(notification) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'spec/support/formatters/steps.rb', line 37

def example_failed notification
  # RSpec::Core::Formatters::ExceptionPresenter is a private class which
  # should not really be used by us, but the snippet extraction and backtrace
  # processing seems rather cumbersome to reimplement
  presenter = RSpec::Core::Formatters::ExceptionPresenter.new(notification.example.execution_result.exception, notification.example, :indentation => 0)
  
  error = presenter.message_lines.map do |line|
    colorize("  #{line}\n",:failure)
  end.join
  @output << error << "\n"

  backtrace = presenter.formatted_backtrace.map do |line|
    colorize("  # #{line}\n",:light_blue)
  end.join
  @output << backtrace << "\n"
end

#example_passed(notification) ⇒ Object

ExampleNotification



33
34
35
# File 'spec/support/formatters/steps.rb', line 33

def example_passed notification # ExampleNotification
  @output << colorize("    Passed\n\n",:success)
end

#example_pending(notification) ⇒ Object



25
26
27
# File 'spec/support/formatters/steps.rb', line 25

def example_pending notification
  @output << colorize("    Pending\n\n", :pending)
end

#example_started(notification) ⇒ Object



29
30
31
# File 'spec/support/formatters/steps.rb', line 29

def example_started notification
  @output << colorize("\n#{notification.example.full_description}\n",:bold)
end

#message(notification) ⇒ Object



21
22
23
# File 'spec/support/formatters/steps.rb', line 21

def message notification
  @output << "  #{notification.message}\n"
end

#start(notification) ⇒ Object



9
10
11
# File 'spec/support/formatters/steps.rb', line 9

def start notification
  @output << "\n"
end

#step(notification) ⇒ Object



17
18
19
# File 'spec/support/formatters/steps.rb', line 17

def step notification
  @output << colorize("    #{notification.message}\n",:cyan)
end

#warning(notification) ⇒ Object



13
14
15
# File 'spec/support/formatters/steps.rb', line 13

def warning notification
  @output << colorize("    Warning: #{notification.message}\n",:yellow)
end