Add to_eventually and to_never operations

This defines what they should look like.
This commit is contained in:
Michael Miller 2019-11-14 18:19:37 -07:00
parent 3666b0e02f
commit bd0396c001

View file

@ -37,6 +37,24 @@ module Spectator::Expectations
to_not(matcher) to_not(matcher)
end end
# Asserts that some criteria defined by the matcher is eventually satisfied.
# The expectation is checked after the example finishes and all hooks have run.
def to_eventually(matcher) : Nil
Harness.current.defer { to(matcher) }
end
# Asserts that some criteria defined by the matcher is never satisfied.
# The expectation is checked after the example finishes and all hooks have run.
def to_never(matcher) : Nil
Harness.current.defer { to_not(matcher) }
end
# ditto
@[AlwaysInline]
def never_to(matcher) : Nil
to_never(matcher)
end
# Reports an expectation to the current harness. # Reports an expectation to the current harness.
private def report(match_data : Matchers::MatchData) private def report(match_data : Matchers::MatchData)
expectation = Expectation.new(match_data, @source) expectation = Expectation.new(match_data, @source)