Add match data docs

This commit is contained in:
Michael Miller 2019-08-10 10:53:00 -06:00
parent d5fd21702a
commit c4b886cad2
3 changed files with 9 additions and 0 deletions

View file

@ -1,15 +1,20 @@
require "./match_data" require "./match_data"
module Spectator::Matchers module Spectator::Matchers
# Information about a failed match.
struct FailedMatchData < MatchData struct FailedMatchData < MatchData
# Indicates that the match failed.
def matched? def matched?
false false
end end
# Description from the matcher as to why it failed.
getter failure_message : String getter failure_message : String
# Additional information from the match that can be used to debug the problem.
getter values : Array(Tuple(Symbol, String)) getter values : Array(Tuple(Symbol, String))
# Creates the match data.
def initialize(@failure_message, **values) def initialize(@failure_message, **values)
@values = values.to_a @values = values.to_a
end end

View file

@ -1,5 +1,7 @@
module Spectator::Matchers module Spectator::Matchers
# Information about the outcome of a match.
abstract struct MatchData abstract struct MatchData
# Indicates whether the match as successful or not.
abstract def matched? : Bool abstract def matched? : Bool
end end
end end

View file

@ -1,7 +1,9 @@
require "./match_data" require "./match_data"
module Spectator::Matchers module Spectator::Matchers
# Information about a successful match.
struct SuccessfulMatchData < MatchData struct SuccessfulMatchData < MatchData
# Indicates that the match succeeded.
def matched? def matched?
true true
end end