struct Spectator::Expectation
- Spectator::Expectation
- Struct
- Value
- Object
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.crConstructors
-
.new(match_data : Matchers::MatchData, location : Location | Nil = nil, message : String | Nil | Proc(String) = nil)
Creates the expectation.
Instance Method Summary
- #description
-
#failed?
Indicates whether the expectation was not met.
-
#failure_message
Description of why the match failed.
-
#failure_message?
If nil, then the match was successful.
-
#location : Location
Location of the expectation in source code.
-
#location? : Location | Nil
Location of the expectation in source code.
-
#satisfied?
Indicates whether the expectation was met.
-
#to_json(json : JSON::Builder)
Creates the JSON representation of the expectation.
-
#values
Additional information about the match, useful for debug.
-
#values?
Additional information about the match, useful for debug.
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 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.
Instance Method Detail
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.
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.
Additional information about the match, useful for debug. If nil, then the match was successful.