Class: RSpec::MultiprocessRunner::ReportingFormatter

Inherits:
Core::Formatters::DocumentationFormatter
  • Object
show all
Defined in:
lib/rspec/multiprocess_runner/reporting_formatter.rb

Overview

RSpec formatter used by workers to communicate spec execution to the coordinator.

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*ignored_args) ⇒ ReportingFormatter

Returns a new instance of ReportingFormatter.



29
30
31
32
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 29

def initialize(*ignored_args)
  super(StringIO.new)
  @current_example_groups = []
end

Class Attribute Details

.workerObject

The worker to which to report spec status. This has to be a class-level attribute because you can’t access the formatter instance used by RSpec’s runner.



26
27
28
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 26

def worker
  @worker
end

Instance Method Details

#example_failed(notification) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 53

def example_failed(notification)
  details = capture_output { super(notification) }
  report_example_result(
    :failed,
    notification.example,
    notification.fully_formatted(1)
  )
end

#example_group_finished(example_group) ⇒ Object



40
41
42
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 40

def example_group_finished(example_group)
  @current_example_groups.pop
end

#example_group_started(notification) ⇒ Object



34
35
36
37
38
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 34

def example_group_started(notification)
  super(notification)

  @current_example_groups.push(notification.group.description.strip)
end

#example_passed(notification) ⇒ Object



44
45
46
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 44

def example_passed(notification)
  report_example_result(:passed, notification.example)
end

#example_pending(notification) ⇒ Object



48
49
50
51
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 48

def example_pending(notification)
  details = capture_output { super(notification) }
  report_example_result(:pending, notification.example, details)
end

#message(struct) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/rspec/multiprocess_runner/reporting_formatter.rb', line 62

def message(struct)
  # this is just for reporting errors not otherwise reported
  return unless RSpec.world.non_example_failure

  message = struct.message
  # skip these as they always come after an error is seems
  return if message =~ /^No examples found./

  worker.report_error(message)
end