Move abstract #match?, #message, and #negated_message to base class

This commit is contained in:
Michael Miller 2019-01-31 13:40:32 -07:00
parent a633d41fae
commit 5ac9020f25
3 changed files with 12 additions and 23 deletions

View file

@ -5,16 +5,5 @@ module Spectator::Matchers
# 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. # Those methods accept a `ValueExpectationPartial` to work with.
abstract struct ConditionMatcher < Matcher 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
end end

View file

@ -11,5 +11,17 @@ module Spectator::Matchers
# Creates the base of the matcher. # Creates the base of the matcher.
private def initialize(@label) private def initialize(@label)
end 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
end end

View file

@ -23,17 +23,5 @@ module Spectator::Matchers
def initialize(@expected : ExpectedType) def initialize(@expected : ExpectedType)
super(@expected.to_s) super(@expected.to_s)
end 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
end end