From af13a89257fb322547347242c5d40ce3954d5d01 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 17 Jul 2021 14:04:17 -0600 Subject: [PATCH] Pass along fallback reason --- src/spectator/pending_example_builder.cr | 6 ++++-- src/spectator/spec_builder.cr | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/spectator/pending_example_builder.cr b/src/spectator/pending_example_builder.cr index c7a1a46..90aaf47 100644 --- a/src/spectator/pending_example_builder.cr +++ b/src/spectator/pending_example_builder.cr @@ -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 diff --git a/src/spectator/spec_builder.cr b/src/spectator/spec_builder.cr index 7b63013..1e03c79 100644 --- a/src/spectator/spec_builder.cr +++ b/src/spectator/spec_builder.cr @@ -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.