struct Spectator::Matchers::TruthyMatcher
  
  - Spectator::Matchers::TruthyMatcher
 - Spectator::Matchers::StandardMatcher
 - Spectator::Matchers::Matcher
 - Struct
 - Value
 - Object
 
Overview
Matcher that tests whether a value is truthy or falsey. Falsey means a value is considered false by an if-statement, which are false and nil in Crystal. Truthy is the opposite of falsey.
Additionally, different matchers can be created
by using the #<, #<=, #>, #>=, #==, and #!= operators.
Defined in:
spectator/matchers/truthy_matcher.crConstructors
- 
        .new(truthy : Bool = true)
        
          
Creates the truthy matcher.
 
Instance Method Summary
- 
        #!=(value)
        
          
Creates a matcher that checks if a value is not equal to an expected value.
 - 
        #<(value)
        
          
Creates a matcher that checks if a value is less than an expected value.
 - 
        #<=(value)
        
          
Creates a matcher that checks if a value is less than or equal to an expected value.
 - 
        #==(value)
        
          
Creates a matcher that checks if a value is equal to an expected value.
 - 
        #===(value)
        
          
Creates a matcher that checks if a value is semantically equal to an expected value.
 - 
        #=~(value)
        
          
Creates a matcher that checks if a value matches the pattern of an expected value.
 - 
        #>(value)
        
          
Creates a matcher that checks if a value is greater than an expected value.
 - 
        #>=(value)
        
          
Creates a matcher that checks if a value is greater than or equal to an expected value.
 - 
        #description : String
        
          
Short text about the matcher's purpose.
 
Instance methods inherited from struct Spectator::Matchers::StandardMatcher
  
  
    
      match(actual : Expression(T)) : MatchData forall T
    match, 
    
  
    
      negated_match(actual : Expression(T)) : MatchData forall T
    negated_match
    
  
    
    
  
    
  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 : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall Ushould(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should, should_eventually(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_eventually, should_never(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_never, should_not(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should_not(matcher : Spectator::Matchers::NilMatcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_not
Constructor Detail
Creates the truthy matcher. The truthy argument should be true to match "truthy" values, and false to match "falsey" values.
Instance Method Detail
Creates a matcher that checks if a value is not equal to an expected value. The spec would look like:
expect(0).to be != 1
        Creates a matcher that checks if a value is less than an expected value. The spec would look like:
expect(0).to be < 1
        Creates a matcher that checks if a value is less than or equal to an expected value. The spec would look like:
expect(0).to be <= 1
        Creates a matcher that checks if a value is equal to an expected value. The spec would look like:
expect(0).to be == 0
        Creates a matcher that checks if a value is semantically equal to an expected value. The spec would look like:
expect("foobar").to be === /foo/
        Creates a matcher that checks if a value matches the pattern of an expected value. The spec would look like:
expect("foobar").to be =~ /foo/
        Creates a matcher that checks if a value is greater than an expected value. The spec would look like:
expect(2).to be > 1
        Creates a matcher that checks if a value is greater than or equal to an expected value. The spec would look like:
expect(2).to be >= 1
        Short text about the matcher's purpose. This explains what condition satisfies the matcher. The description is used when the one-liner syntax is used.