Add pass?/fail? methods to Result types

This commit is contained in:
Michael Miller 2021-05-12 21:39:50 -06:00
parent 72b2e7ebcb
commit b8b6b3b609
No known key found for this signature in database
GPG key ID: F9A0C5C65B162436
4 changed files with 36 additions and 0 deletions

View file

@ -25,6 +25,16 @@ module Spectator
visitor.failure(yield self)
end
# Indicates whether the example passed.
def pass? : Bool
false
end
# Indicates whether the example failed.
def fail? : Bool
true
end
# One-word description of the result.
def to_s(io)
io << "fail"

View file

@ -13,6 +13,16 @@ module Spectator
visitor.pass(yield self)
end
# Indicates whether the example passed.
def pass? : Bool
true
end
# Indicates whether the example failed.
def fail? : Bool
false
end
# One-word description of the result.
def to_s(io)
io << "pass"

View file

@ -21,6 +21,16 @@ module Spectator
visitor.pending(yield self)
end
# Indicates whether the example passed.
def pass? : Bool
false
end
# Indicates whether the example failed.
def fail? : Bool
false
end
# One-word description of the result.
def to_s(io)
io << "pending"

View file

@ -17,6 +17,12 @@ module Spectator
# This is the visitor design pattern.
abstract def accept(visitor)
# Indicates whether the example passed.
abstract def pass? : Bool
# Indicates whether the example failed.
abstract def fail? : Bool
# Creates a JSON object from the result information.
def to_json(json : ::JSON::Builder, example)
json.object do