From b625cb69cff44b8177288a0cbc06e9b4818563af Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 13 Nov 2018 14:17:37 -0700 Subject: [PATCH] Adopt partials to use new Expectation type --- src/spectator/expectations/expectation_partial.cr | 5 +++++ src/spectator/expectations/value_expectation_partial.cr | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/spectator/expectations/expectation_partial.cr b/src/spectator/expectations/expectation_partial.cr index f10b1c8..b111fd6 100644 --- a/src/spectator/expectations/expectation_partial.cr +++ b/src/spectator/expectations/expectation_partial.cr @@ -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 diff --git a/src/spectator/expectations/value_expectation_partial.cr b/src/spectator/expectations/value_expectation_partial.cr index 0351114..ddbee9a 100644 --- a/src/spectator/expectations/value_expectation_partial.cr +++ b/src/spectator/expectations/value_expectation_partial.cr @@ -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