Module: Mutineer::MinitestIntegration::OuterReporter
- Defined in:
- lib/mutineer/minitest_integration/outer_reporter.rb
Overview
Finds the outer reporter of a Minitest run, for the hooks that act only on the run's own results. A test can build a reporter of its own and record on it, or start a nested run, so the first reporter the run hands to its suites is the one that counts. Child-process only, like MinitestIntegration.
A client module extends Client, registers here, and sets its armed pid. The hook then gives the outer reporter to each client armed in this process. Minitest 5 and 6 need different hook points; an unknown shape gets no hook.
Defined Under Namespace
Class Method Summary collapse
-
.clients ⇒ Array<Module>
The registered clients, in registration order.
-
.hook_for_loaded_minitest ⇒ Module?
The outer-reporter hook for the loaded Minitest.
-
.prepend_once(target, mod) ⇒ void
Prepends
modontargetonce. -
.register(client) ⇒ void
Registers a client once.
-
.seen(reporter) ⇒ void
Gives
reporterto every client armed in this process that has no outer reporter yet.
Class Method Details
.clients ⇒ Array<Module>
The registered clients, in registration order.
77 78 79 |
# File 'lib/mutineer/minitest_integration/outer_reporter.rb', line 77 def clients @clients ||= [] end |
.hook_for_loaded_minitest ⇒ Module?
The outer-reporter hook for the loaded Minitest.
103 104 105 106 107 108 109 110 |
# File 'lib/mutineer/minitest_integration/outer_reporter.rb', line 103 def hook_for_loaded_minitest runnable = ::Minitest::Runnable if ::Minitest.respond_to?(:run_all_suites) && runnable.respond_to?(:run_suite) Hook6 elsif ::Minitest.respond_to?(:__run) && runnable.respond_to?(:run_one_method) Hook5 end end |
.prepend_once(target, mod) ⇒ void
This method returns an undefined value.
Prepends mod on target once. A copy on a superclass does not
count, because it comes after the own methods of target.
118 119 120 121 122 |
# File 'lib/mutineer/minitest_integration/outer_reporter.rb', line 118 def prepend_once(target, mod) return if target.ancestors.take_while { |a| !a.equal?(target) }.include?(mod) target.prepend(mod) end |
.register(client) ⇒ void
This method returns an undefined value.
Registers a client once.
85 86 87 |
# File 'lib/mutineer/minitest_integration/outer_reporter.rb', line 85 def register(client) clients << client unless clients.include?(client) end |
.seen(reporter) ⇒ void
This method returns an undefined value.
Gives reporter to every client armed in this process that has no
outer reporter yet.
94 95 96 97 98 |
# File 'lib/mutineer/minitest_integration/outer_reporter.rb', line 94 def seen(reporter) clients.each do |client| client.armed_reporter ||= reporter if client.armed_here? end end |