Class: Spectus::Requirement::Base
- Inherits:
-
Object
- Object
- Spectus::Requirement::Base
- Defined in:
- lib/spectus/requirement/base.rb
Overview
Base class for implementing RFC 2119 requirement levels.
This class provides the core functionality for running tests against different requirement levels (MUST, SHOULD, MAY). It uses TestTube for test execution and Expresenter for result presentation.
Direct Known Subclasses
Instance Method Summary collapse
-
#call { ... } ⇒ ::Expresenter::Pass
Execute the test and return its result.
-
#initialize(matcher:, negate:) ⇒ Base
constructor
Initialize the requirement level class.
Constructor Details
#initialize(matcher:, negate:) ⇒ Base
Initialize the requirement level class.
24 25 26 27 28 29 |
# File 'lib/spectus/requirement/base.rb', line 24 def initialize(matcher:, negate:) raise ::ArgumentError, "matcher must respond to match?" unless matcher.respond_to?(:match?) @matcher = matcher @negate = negate end |
Instance Method Details
#call { ... } ⇒ ::Expresenter::Pass
Execute the test and return its result.
Runs the provided block through the matcher and evaluates the result according to the requirement level’s rules. The result is presented through an Expresenter instance containing all test details.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/spectus/requirement/base.rb', line 47 def call(&) test = ::TestTube.invoke(matcher: @matcher, negate: @negate, &) ::Expresenter.call(passed?(test)).with( actual: test.actual, definition: @matcher.to_s, error: test.error, got: test.got, level: self.class.level, negate: @negate ) end |