Class: Sus::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/sus/registry.rb

Overview

Represents a registry of test files and contexts.

Constant Summary collapse

DIRECTORY_GLOB =

The glob pattern used to find Ruby files in directories.

"**/*.rb"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Registry

Initialize a new registry.



29
30
31
32
# File 'lib/sus/registry.rb', line 29

def initialize(**options)
	@base = Sus.base(self, **options)
	@loaded = {}
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



35
36
37
# File 'lib/sus/registry.rb', line 35

def base
  @base
end

Instance Method Details

#call(assertions = Assertions.default) ⇒ Object

Execute all tests in the registry.



73
74
75
76
77
# File 'lib/sus/registry.rb', line 73

def call(assertions = Assertions.default)
	@base.call(assertions)
	
	return assertions
end

#childrenObject



86
87
88
# File 'lib/sus/registry.rb', line 86

def children
	@base.children
end

#eachObject

Iterate over all test cases in the registry.



81
82
83
# File 'lib/sus/registry.rb', line 81

def each(...)
	@base.each(...)
end

#load(path) ⇒ Object

Load a test file or directory.



50
51
52
53
54
55
56
# File 'lib/sus/registry.rb', line 50

def load(path)
	if ::File.directory?(path)
		load_directory(path)
	else
		load_file(path)
	end
end

Print a representation of this registry.



39
40
41
# File 'lib/sus/registry.rb', line 39

def print(output)
	output.write("Test Registry")
end

#The base test context class.=(basetestcontext) ⇒ Object



35
# File 'lib/sus/registry.rb', line 35

attr :base

#to_sObject



44
45
46
# File 'lib/sus/registry.rb', line 44

def to_s
	@base&.identity&.to_s || self.class.name
end