Class: Spectus::Requirement::Required

Inherits:
Base
  • Object
show all
Defined in:
lib/spectus/requirement/required.rb

Overview

Implementation of MUST/MUST NOT requirements from RFC 2119.

This level represents an absolute requirement - tests at this level must pass without any exceptions or conditions. Unlike SHOULD or MAY levels, there is no flexibility in what constitutes a passing test.

The test passes only when:

  • MUST: The matcher returns true (when negate: false)

  • MUST NOT: The matcher returns false (when negate: true)

Examples:

Testing a MUST requirement

test = Required.new(matcher: some_matcher, negate: false)
test.call { value } # Passes only if matcher returns true

Testing a MUST NOT requirement

test = Required.new(matcher: some_matcher, negate: true)
test.call { value } # Passes only if matcher returns false

See Also:

Class Method Summary collapse

Methods inherited from Base

#call, #initialize

Constructor Details

This class inherits a constructor from Spectus::Requirement::Base

Class Method Details

.levelSymbol

The RFC 2119 keyword for this requirement level.

Returns:

  • (Symbol)

    :MUST indicating an absolute requirement



31
32
33
# File 'lib/spectus/requirement/required.rb', line 31

def self.level
  :MUST
end