Module: Evilution::Integration::TestUnit::SubjectClassRegistry

Defined in:
lib/evilution/integration/test_unit/subject_class_registry.rb

Overview

Tracks Test::Unit::TestCase descendants in the host process. Test::Unit has no public registry-clear method analogous to Minitest::Runnable.runnables; the integration scopes each dispatch to classes that appeared during this round by diffing the descendant set before and after #load. Keeping that responsibility in its own object makes it cheap to stub in tests and lets the integration’s main class read as orchestration.

Class Method Summary collapse

Class Method Details

.descendantsObject



14
15
16
17
18
# File 'lib/evilution/integration/test_unit/subject_class_registry.rb', line 14

def descendants
  return [] unless defined?(::Test::Unit::TestCase)

  ObjectSpace.each_object(Class).select { |c| c < ::Test::Unit::TestCase }
end

.newly_loadedObject

Yields, captures the descendant set before/after, and returns the diff.



21
22
23
24
25
# File 'lib/evilution/integration/test_unit/subject_class_registry.rb', line 21

def newly_loaded
  before = descendants
  yield
  descendants - before
end