Class: Spectus::Requirement::Optional

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

Overview

Implementation of MAY requirements from RFC 2119.

This level represents optional features. A test at this level passes in two cases:

  • When the feature is implemented and the matcher returns true

  • When NoMethodError is raised, indicating the feature is not implemented

Examples:

Testing a MAY requirement with implemented feature

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

Testing a MAY requirement with unimplemented feature

test = Optional.new(matcher: some_matcher, negate: false)
test.call { unimplemented_feature } # Passes if NoMethodError is raised

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)

    :MAY indicating an optional requirement



28
29
30
# File 'lib/spectus/requirement/optional.rb', line 28

def self.level
  :MAY
end