Method: Spectus.may
- Defined in:
- lib/spectus.rb
.may(matcher) ⇒ Requirement::Optional
Defines an optional feature or behavior. This represents the RFC 2119 “MAY” level - where an item is truly optional. Implementations can freely choose whether to include the item based on their specific needs, while maintaining interoperability with other implementations.
For MAY requirements, a test passes in two cases:
-
When a NoMethodError is raised, indicating the feature is not implemented
-
When the feature is implemented and the test succeeds
203 204 205 206 207 |
# File 'lib/spectus.rb', line 203 def self.may(matcher) raise ::ArgumentError, "matcher must respond to match?" unless matcher.respond_to?(:match?) Requirement::Optional.new(negate: false, matcher:) end |