Adopt partials to use new Expectation type

This commit is contained in:
Michael Miller 2018-11-13 14:17:37 -07:00
parent 718f24aef3
commit b625cb69cf
2 changed files with 7 additions and 6 deletions

View file

@ -20,5 +20,10 @@ module Spectator::Expectations
# Creates the base of the partial.
private def initialize(@label)
end
# Reports an expectation to the current harness.
private def report(expectation : Expectation)
Internals::Harness.current.report_expectation(expectation)
end
end
end

View file

@ -24,17 +24,13 @@ module Spectator::Expectations
# Asserts that the `#actual` value matches some criteria.
# The criteria is defined by the matcher passed to this method.
def to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
expectation = ValueExpectation.new(self, matcher)
result = expectation.eval
Internals::Harness.current.report_expectation(result)
report(matcher.eval(self))
end
# Asserts that the `#actual` value *does not* match some criteria.
# This is effectively the opposite of `#to`.
def to_not(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
expectation = ValueExpectation.new(self, matcher)
result = expectation.eval(true)
Internals::Harness.current.report_expectation(result)
report(matcher.eval(self, true))
end
# ditto