Pass along fallback reason

This commit is contained in:
Michael Miller 2021-07-17 14:04:17 -06:00
parent 1b53607f8e
commit af13a89257
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
2 changed files with 5 additions and 3 deletions

View file

@ -9,14 +9,16 @@ module Spectator
class PendingExampleBuilder < NodeBuilder
# Creates the builder.
# The *name*, *location*, and *metadata* will be applied to the `Example` produced by `#build`.
def initialize(@name : String? = nil, @location : Location? = nil, @metadata : Metadata = Metadata.new)
# A default *reason* can be given in case the user didn't provide one.
def initialize(@name : String? = nil, @location : Location? = nil,
@metadata : Metadata = Metadata.new, @reason : String? = nil)
end
# Constructs an example with previously defined attributes.
# The *parent* is an already constructed example group to nest the new example under.
# It can be nil if the new example won't have a parent.
def build(parent = nil)
Example.pending(@name, @location, parent, @metadata)
Example.pending(@name, @location, parent, @metadata, @reason)
end
end
end

View file

@ -132,7 +132,7 @@ module Spectator
# A default *reason* can be given in case the user didn't provide one.
def add_pending_example(name, location, metadata = Metadata.new, reason = nil) : Nil
Log.trace { "Add pending example: #{name} @ #{location}; metadata: #{metadata}" }
current << PendingExampleBuilder.new(name, location, metadata)
current << PendingExampleBuilder.new(name, location, metadata, reason)
end
# Attaches a hook to be invoked before any and all examples in the current group.