struct Spectator::Expectation

Overview

Result of evaluating a matcher on a target. Contains information about the match, such as whether it was successful and a description of the operation.

Defined in:

spectator/expectation.cr

Constructors

Instance Method Summary

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

Constructor Detail

def self.new(match_data : Matchers::MatchData, location : Location? = nil, message : String? | Proc(String) = nil) #

Creates the expectation. The match_data comes from the result of calling Matcher#match. The location is the location of the expectation in source code, if available. A custom message can be used in case of a failure.


[View source]

Instance Method Detail

def description #

[View source]
def failed? #

Indicates whether the expectation was not met.


[View source]
def failure_message #

Description of why the match failed.


[View source]
def failure_message? #

If nil, then the match was successful.


[View source]
def location : Location #

Location of the expectation in source code. This can be nil if the location isn't capturable, for instance using the should syntax or dynamically created expectations.


[View source]
def location? : Location? #

Location of the expectation in source code. This can be nil if the location isn't capturable, for instance using the should syntax or dynamically created expectations.


[View source]
def satisfied? #

Indicates whether the expectation was met.


[View source]
def to_json(json : JSON::Builder) #

Creates the JSON representation of the expectation.


[View source]
def values #

Additional information about the match, useful for debug.


[View source]
def values? #

Additional information about the match, useful for debug. If nil, then the match was successful.


[View source]