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. # Creates the base of the partial.
private def initialize(@label) private def initialize(@label)
end end
# Reports an expectation to the current harness.
private def report(expectation : Expectation)
Internals::Harness.current.report_expectation(expectation)
end
end end
end end

View file

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