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 : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should(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

def self.new(match_data : Matchers::MatchData, location : Location | Nil = nil, message : String | Nil | 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 can't be captured, for instance using the should syntax or dynamically created expectations.


[View source]
def location? : Location | Nil #

Location of the expectation in source code. This can be nil if the location can't be captured, 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]