abstract struct Spectator::Matchers::StandardMatcher
Overview
Provides common methods for matchers.
The #match and #negated_match methods have an implementation
that is suitable for most matchers.
Matchers based on this class need to define #match? and #failure_message.
If the matcher can be negated,
the #failure_message_when_negated method needs to be overridden.
Additionally, the #does_not_match? method can be specified
if there's custom behavior for negated matches.
If the matcher operates on or has extra data that is useful for debug,
then the #values and #negated_values methods can be overridden.
Finally, define a #description message that can be used for the one-liner "it" syntax.
Direct Known Subclasses
- Spectator::Matchers::CompiledTypeMatcher(Expected)
- Spectator::Matchers::EmptyMatcher
- Spectator::Matchers::InstanceMatcher(Expected)
- Spectator::Matchers::NilMatcher
- Spectator::Matchers::ReceiveMatcher
- Spectator::Matchers::ReceiveTypeMatcher
- Spectator::Matchers::TruthyMatcher
- Spectator::Matchers::TypeMatcher(Expected)
- Spectator::Matchers::ValueMatcher(ExpectedType)
Defined in:
spectator/matchers/standard_matcher.crInstance Method Summary
- 
        #match(actual : Expression(T)) : MatchData forall T
        
          Actually performs the test against the expression (value or block). 
- 
        #negated_match(actual : Expression(T)) : MatchData forall T
        
          Performs the test against the expression (value or block), but inverted. 
Instance methods inherited from struct Spectator::Matchers::Matcher
  
  
    
      description : String
    description, 
    
  
    
      initialize
    initialize, 
    
  
    
      match(actual : Expression(T)) : MatchData forall T
    match, 
    
  
    
      negated_match(actual : Expression(T)) : MatchData forall T
    negated_match
    
  
    
  Constructor methods inherited from struct Spectator::Matchers::Matcher
  
  
    
      new
    new
    
  
    
  
    
    
    
  
    
    
    
  
    
  Instance methods inherited from class Object
  
  
    
      should(matcher, message = nil)
    should, 
    
  
    
      should_eventually(matcher, message = nil)
    should_eventually, 
    
  
    
      should_never(matcher, message = nil)
    should_never, 
    
  
    
      should_not(matcher, message = nil)
    should_not
    
  
    
    
  
Instance Method Detail
Actually performs the test against the expression (value or block).
This method calls the abstract #match? method.
If it returns true, then a SuccessfulMatchData instance is returned.
Otherwise, a FailedMatchData instance is returned.
Additionally, #failure_message and #values are called for a failed match.
Performs the test against the expression (value or block), but inverted.
A successful match with #match should normally fail for this method, and vice-versa.
This method calls the abstract #does_not_match? method.
If it returns true, then a SuccessfulMatchData instance is returned.
Otherwise, a FailedMatchData instance is returned.
Additionally, #failure_message_when_negated and #negated_values are called for a failed match.