From d738494fdf1baea8eb77f679c2f2de98ea3b31f2 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 16 Jan 2021 11:49:43 -0700 Subject: [PATCH] Cleanup example name output --- src/spectator/example.cr | 10 ++++++++++ src/spectator/spec_node.cr | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/spectator/example.cr b/src/spectator/example.cr index a90931e..5ff9750 100644 --- a/src/spectator/example.cr +++ b/src/spectator/example.cr @@ -82,6 +82,16 @@ module Spectator with context yield end + # Constructs the full name or description of the example. + # This prepends names of groups this example is part of. + def to_s(io) + if name? + super + else + io << "" + end + end + # Exposes information about the example useful for debugging. def inspect(io) # Full example name. diff --git a/src/spectator/spec_node.cr b/src/spectator/spec_node.cr index a559938..7a00173 100644 --- a/src/spectator/spec_node.cr +++ b/src/spectator/spec_node.cr @@ -53,7 +53,7 @@ module Spectator # Prefix with group's full name if the node belongs to a group. if (group = @group) - io << group + group.to_s(io) # Add padding between the node names # only if the names don't appear to be symbolic. @@ -63,7 +63,7 @@ module Spectator (name.starts_with?('#') || name.starts_with?('.'))) end - io << name + name.to_s(io) end end end