class Registry
Represents a registry of test files and contexts.
Definitions
DIRECTORY_GLOB = "**/*.rb"
The glob pattern used to find Ruby files in directories.
def initialize(**options)
Initialize a new registry.
Signature
-
parameter
optionsHash Options to pass to the base context.
Implementation
def initialize(**options)
@base = Sus.base(self, **options)
@loaded = {}
end
attr :base
Signature
-
attribute
Class The base test context class.
def print(output)
Print a representation of this registry.
Signature
-
parameter
outputOutput The output target.
Implementation
def print(output)
output.write("Test Registry")
end
def to_s
Signature
-
returns
String A string representation of this registry.
Implementation
def to_s
@base&.identity&.to_s || self.class.name
end
def load(path)
Load a test file or directory.
Signature
-
parameter
pathString The path to load (file or directory).
Implementation
def load(path)
if ::File.directory?(path)
load_directory(path)
else
load_file(path)
end
end
def call(assertions = Assertions.default)
Execute all tests in the registry.
Signature
-
parameter
assertionsAssertions Optional assertions instance to use.
-
returns
Assertions The assertions instance with results.
Implementation
def call(assertions = Assertions.default)
@base.call(assertions)
return assertions
end
def each(...)
Iterate over all test cases in the registry.
Signature
-
yields
{|test| ...} Each test case.
Implementation
def each(...)
@base.each(...)
end
def children
Signature
-
returns
Hash The child contexts and tests.
Implementation
def children
@base.children
end