Check pending, skip, and reason tags for reason

This commit is contained in:
Michael Miller 2021-06-11 19:29:29 -06:00
parent 12cba23fa3
commit a061bd2044
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
2 changed files with 9 additions and 1 deletions

View file

@ -89,7 +89,7 @@ module Spectator
if pending?
Log.debug { "Skipping example #{self} - marked pending" }
@finished = true
return @result = PendingResult.new(tags[:pending] || PendingResult::DEFAULT_REASON)
return @result = PendingResult.new(pending_reason)
end
previous_example = @@current

View file

@ -7,6 +7,9 @@ module Spectator
# This is commonly an `Example` or `ExampleGroup`,
# but can be anything that should be iterated over when running the spec.
abstract class Node
# Default text used if none was given by the user for skipping a node.
DEFAULT_PENDING_REASON = "No reason given"
# Location of the node in source code.
getter! location : Location
@ -46,6 +49,11 @@ module Spectator
tags.has_key?(:pending) || tags.has_key?(:skip)
end
# Gets the reason the node has been marked as pending.
def pending_reason
tags[:pending]? || tags[:skip]? || tags[:reason]? || DEFAULT_PENDING_REASON
end
# Constructs the full name or description of the node.
# This prepends names of groups this node is part of.
def to_s(io)