struct Spectator::Matchers::TruthyMatcher

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.cr

Constructors

Instance Method Summary

Instance methods inherited from struct Spectator::Matchers::StandardMatcher

match(actual : TestExpression(T)) : MatchData forall T match, negated_match(actual : TestExpression(T)) : MatchData forall T negated_match

Instance methods inherited from struct Spectator::Matchers::Matcher

description : String description, initialize initialize, match(actual : TestExpression(T)) : MatchData forall T match, negated_match(actual : TestExpression(T)) : MatchData forall T negated_match

Constructor methods inherited from struct Spectator::Matchers::Matcher

new new

Instance methods inherited from class Object

should(matcher) should, should_eventually(matcher) should_eventually, should_never(matcher) should_never, should_not(matcher) should_not

Constructor Detail

def self.new(truthy : Bool = true) #

Creates the truthy matcher. The truthy argument should be true to match "truthy" values, and false to match "falsey" values.


[View source]

Instance Method Detail

def !=(value) #

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

[View source]
def <(value) #

Creates a matcher that checks if a value is less than an expected value. The spec would look like:

expect(0).to be < 1

[View source]
def <=(value) #

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

[View source]
def ==(value) #

Creates a matcher that checks if a value is equal to an expected value. The spec would look like:

expect(0).to be == 0

[View source]
def >(value) #

Creates a matcher that checks if a value is greater than an expected value. The spec would look like:

expect(2).to be > 1

[View source]
def >=(value) #

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

[View source]
def description : String #

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.


[View source]