struct Spectator::Expectation::Target(T)

Overview

Stores part of an expectation. This covers the actual value (or block) being inspected and its location. This is the type returned by an expect block in the DSL. It is not intended to be used directly, but instead by chaining methods. Typically #to and #not_to are used.

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(expression : Expression(T), location : Location) #

Creates the expectation target. The expression is the actual value being tested and its label. The location is the location of where this expectation was defined.


[View source]

Instance Method Detail

def never_to(stub : Stub, message = nil) : Nil #

Asserts that a method is not called before the example completes.


[View source]
def never_to(matcher, message = nil) : Nil #

Asserts that some criteria defined by the matcher is never satisfied. The expectation is checked after the example finishes and all hooks have run. Allows a custom message to be used.


[View source]
def not_to(stub : Stub, message = nil) : Nil #

Asserts that a method is not called before the example completes.


[View source]
def not_to(matcher, message = nil) : Nil #

Asserts that some criteria defined by the matcher is not satisfied. Allows a custom message to be used. Returns the expected value cast as a non-nillable type, if the matcher is satisfied.


[View source]
def to(matcher : Matchers::TypeMatcher(U), message = nil) forall U #

Asserts that some criteria defined by the matcher is satisfied. Allows a custom message to be used. Returns the expected value cast as the expected type, if the matcher is satisfied.


[View source]
def to(stub : Stub, message = nil) : Nil #

Asserts that a method is called some point before the example completes.


[View source]
def to(matcher, message = nil) : Nil #

Asserts that some criteria defined by the matcher is satisfied. Allows a custom message to be used.


[View source]
def to_eventually(stub : Stub, message = nil) : Nil #

Asserts that a method is called some point before the example completes.


[View source]
def to_eventually(matcher, message = nil) : Nil #

Asserts that some criteria defined by the matcher is eventually satisfied. The expectation is checked after the example finishes and all hooks have run. Allows a custom message to be used.


[View source]
def to_never(stub : Stub, message = nil) : Nil #

Asserts that a method is not called before the example completes.


[View source]
def to_never(matcher, message = nil) : Nil #

Asserts that some criteria defined by the matcher is never satisfied. The expectation is checked after the example finishes and all hooks have run. Allows a custom message to be used.


[View source]
def to_not(matcher : Matchers::TypeMatcher(U), message = nil) forall U #

Asserts that some criteria defined by the matcher is not satisfied. Allows a custom message to be used. Returns the expected value cast without the unexpected type, if the matcher is satisfied.


[View source]
def to_not(stub : Stub, message = nil) : Nil #

Asserts that a method is not called before the example completes.


[View source]
def to_not(matcher : Matchers::NilMatcher, message = nil) #

Asserts that some criteria defined by the matcher is not satisfied. Allows a custom message to be used. Returns the expected value cast as a non-nillable type, if the matcher is satisfied.


[View source]
def to_not(matcher, message = nil) : Nil #

Asserts that some criteria defined by the matcher is not satisfied. This is effectively the opposite of #to. Allows a custom message to be used.


[View source]