Class: Fix::Set Private
- Inherits:
-
Object
- Object
- Fix::Set
- Defined in:
- lib/fix/set.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A Set represents a collection of test specifications that can be executed as a test suite. It manages the lifecycle of specifications, including:
-
Building and loading specifications from contexts
-
Executing specifications in isolation using process forking
-
Reporting test results
-
Managing test execution flow and exit status
Class Method Summary collapse
-
.build(name) { ... } ⇒ Fix::Set
private
Builds a new Set from a specification block.
-
.load(name) ⇒ Fix::Set
private
Loads a previously registered specification set by name.
Instance Method Summary collapse
-
#initialize(*contexts) ⇒ Set
constructor
private
Initializes a new Set with given test contexts.
-
#match? { ... } ⇒ Boolean
Verifies if a subject matches all specifications without exiting.
-
#test { ... } ⇒ Boolean
Executes the complete test suite against a subject.
-
#to_s ⇒ String
Returns a string representation of the test set.
Constructor Details
#initialize(*contexts) ⇒ Set
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a new Set with given test contexts.
The contexts are processed to extract test specifications and randomized to ensure test isolation and catch order dependencies.
84 85 86 |
# File 'lib/fix/set.rb', line 84 def initialize(*contexts) @expected = Doc.extract_specifications(*contexts).shuffle end |
Class Method Details
.build(name) { ... } ⇒ Fix::Set
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds a new Set from a specification block.
This method:
-
Creates a new DSL class for the specification
-
Evaluates the specification block in this context
-
Optionally registers the specification under a name
-
Returns a Set instance ready for testing
53 54 55 56 57 58 59 |
# File 'lib/fix/set.rb', line 53 def self.build(name, &block) klass = ::Class.new(Dsl) klass.const_set(:CONTEXTS, [klass]) klass.instance_eval(&block) Doc.const_set(name, klass) unless name.nil? new(*klass.const_get(:CONTEXTS)) end |
.load(name) ⇒ Fix::Set
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads a previously registered specification set by name.
71 72 73 |
# File 'lib/fix/set.rb', line 71 def self.load(name) new(*Doc.fetch(name)) end |
Instance Method Details
#match? { ... } ⇒ Boolean
Verifies if a subject matches all specifications without exiting.
This method is useful for:
-
Conditional testing where exit on failure is not desired
-
Integration into larger test suites
-
Programmatic test result handling
111 112 113 114 115 |
# File 'lib/fix/set.rb', line 111 def match?(&subject) raise Error::MissingSubjectBlock unless subject expected.all? { |spec| run_spec(*spec, &subject) } end |
#test { ... } ⇒ Boolean
Executes the complete test suite against a subject.
This method provides a comprehensive test run that:
-
Executes all specifications in random order
-
Runs each test in isolation via process forking
-
Reports results for each specification
-
Exits with appropriate status code
142 143 144 |
# File 'lib/fix/set.rb', line 142 def test(&subject) match?(&subject) || exit_with_failure end |
#to_s ⇒ String
Returns a string representation of the test set.
154 155 156 |
# File 'lib/fix/set.rb', line 154 def to_s "fix #{expected.inspect}" end |