Class: RSpec::Distrib::Leader::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/distrib/leader/reporter.rb

Overview

RSpec reporter local to the leader, but reachable by Workers. Used to accumulate the example execution results from worker machines.

Constant Summary collapse

FAILED_STATUSES =

Failed statuses for an example

%w[failed].freeze
REPORTABLE_EXAMPLE_STATUSES =

Possible example statuses

(%w[passed pending] + FAILED_STATUSES).freeze

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



17
18
19
20
# File 'lib/rspec/distrib/leader/reporter.rb', line 17

def initialize
  @reporter = init_reporter
  @reporter.start(Leader::FAKE_TOTAL_EXAMPLES_COUNT)
end

Instance Method Details

#failures?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/rspec/distrib/leader/reporter.rb', line 54

def failures?
  reporter.failed_examples.any?
end

#finishObject

Print the final results of the test suite



43
44
45
# File 'lib/rspec/distrib/leader/reporter.rb', line 43

def finish
  reporter.finish
end

#notify_non_example_exception(exception, context_description) ⇒ Object

Notifies RSpec about exceptions unrelated to an example in order to halt execution

Parameters:

  • exception (Exception)


50
51
52
# File 'lib/rspec/distrib/leader/reporter.rb', line 50

def notify_non_example_exception(exception, context_description)
  reporter.notify_non_example_exception(exception, context_description)
end

#report(example_group, will_be_retried: false) ⇒ Object

Note:

This is only supporting RSpec “Progress” formatter for now.

To report the file and all its specs results.

We’re doing this by file, so that the results keeps readable in any format, even if multiple workers are sending results at the same time.

Parameters:

See Also:



31
32
33
34
35
36
37
38
39
40
# File 'lib/rspec/distrib/leader/reporter.rb', line 31

def report(example_group, will_be_retried: false)
  reporter.example_group_started(example_group)

  example_group.examples.each { |example| report_example(example, will_be_retried:) }
  example_group.children.each do |inner_example_group|
    report(inner_example_group, will_be_retried:)
  end

  reporter.example_group_finished(example_group)
end