From 718f24aef3f0a683b14a037b095ebffd203e2292 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 13 Nov 2018 14:11:51 -0700 Subject: [PATCH] Adopt ValueMatcher to new Expectation type --- src/spectator/matchers/value_matcher.cr | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/spectator/matchers/value_matcher.cr b/src/spectator/matchers/value_matcher.cr index 3295ca5..3073e53 100644 --- a/src/spectator/matchers/value_matcher.cr +++ b/src/spectator/matchers/value_matcher.cr @@ -3,7 +3,7 @@ require "./matcher" module Spectator::Matchers # Category of matcher that uses a value. # Matchers of this type expect that a SUT applies to the value in some way. - # Sub-types must implement `#match`, `#message`, and `#negated_message`. + # Sub-types must implement `#match?`, `#message`, and `#negated_message`. # Those methods accept a `ValueExpectationPartial` to work with. abstract struct ValueMatcher(ExpectedType) < Matcher # Expected value. @@ -25,7 +25,14 @@ module Spectator::Matchers end # Determines whether the matcher is satisfied with the value given to it. - # True is returned if the match was successful, false otherwise. + # An `Expectation` is returned containing all match information. + def eval(partial : ValueExpectationPartial(ActualType), negated = false) : Expectation forall ActualType + matched = match?(partial) + ValueExpectation.new(matched, negated, partial, self) + end + + # Determines whether the matcher is satisfied with the value given to it. + # True is returned if the matcher is satisfied, false otherwise. abstract def match?(partial : ValueExpectationPartial(ActualType)) : Bool forall ActualType # Describes the condition that satisfies the matcher.