From 5ac9020f2530cb899471a63f32e81d005fdf458f Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 31 Jan 2019 13:40:32 -0700 Subject: [PATCH] Move abstract #match?, #message, and #negated_message to base class --- src/spectator/matchers/condition_matcher.cr | 11 ----------- src/spectator/matchers/matcher.cr | 12 ++++++++++++ src/spectator/matchers/value_matcher.cr | 12 ------------ 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/spectator/matchers/condition_matcher.cr b/src/spectator/matchers/condition_matcher.cr index bf9d7ba..8603c61 100644 --- a/src/spectator/matchers/condition_matcher.cr +++ b/src/spectator/matchers/condition_matcher.cr @@ -5,16 +5,5 @@ module Spectator::Matchers # Sub-types must implement `#match?`, `#message`, and `#negated_message`. # Those methods accept a `ValueExpectationPartial` to work with. abstract struct ConditionMatcher < Matcher - # 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) : Bool - - # Describes the condition that satisfies the matcher. - # This is informational and displayed to the end-user. - abstract def message(partial) : String - - # Describes the condition that won't satsify the matcher. - # This is informational and displayed to the end-user. - abstract def negated_message(partial) : String end end diff --git a/src/spectator/matchers/matcher.cr b/src/spectator/matchers/matcher.cr index b3b50bc..ae4e4f8 100644 --- a/src/spectator/matchers/matcher.cr +++ b/src/spectator/matchers/matcher.cr @@ -11,5 +11,17 @@ module Spectator::Matchers # Creates the base of the matcher. private def initialize(@label) end + + # Determines whether the matcher is satisfied with the value given to it. + # True is returned if the match was successful, false otherwise. + abstract def match?(partial) : Bool + + # Describes the condition that satisfies the matcher. + # This is informational and displayed to the end-user. + abstract def message(partial) : String + + # Describes the condition that won't satsify the matcher. + # This is informational and displayed to the end-user. + abstract def negated_message(partial) : String end end diff --git a/src/spectator/matchers/value_matcher.cr b/src/spectator/matchers/value_matcher.cr index aab946c..59272ad 100644 --- a/src/spectator/matchers/value_matcher.cr +++ b/src/spectator/matchers/value_matcher.cr @@ -23,17 +23,5 @@ module Spectator::Matchers def initialize(@expected : ExpectedType) super(@expected.to_s) 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) : Bool - - # Describes the condition that satisfies the matcher. - # This is informational and displayed to the end-user. - abstract def message(partial) : String - - # Describes the condition that won't satsify the matcher. - # This is informational and displayed to the end-user. - abstract def negated_message(partial) : String end end