struct

Spectator::Expectation

Inherits Struct / Value / Object

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.

Constructors

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.

Source

Instance methods

description
Source
failed?

Indicates whether the expectation was not met.

Source
failure_message

Description of why the match failed.

Source
failure_message?

If nil, then the match was successful.

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

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

Source
satisfied?

Indicates whether the expectation was met.

Source
to_json(json : JSON::Builder)

Creates the JSON representation of the expectation.

Source
values

Additional information about the match, useful for debug.

Source
values?

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

Source

Nested types