From aee171656ad0e4401930e92d94d193051599a40c Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 16 May 2021 19:37:45 -0600 Subject: [PATCH] Fix '' showing up for root group --- src/spectator/example_group.cr | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/spectator/example_group.cr b/src/spectator/example_group.cr index 8031e20..4c9ae9e 100644 --- a/src/spectator/example_group.cr +++ b/src/spectator/example_group.cr @@ -121,19 +121,18 @@ module Spectator # Constructs the full name or description of the example group. # This prepends names of groups this group is part of. def to_s(io) + # Prefix with group's full name if the node belongs to a group. + return unless parent = @group + + parent.to_s(io) name = @name - # Prefix with group's full name if the node belongs to a group. - if (parent = @group) - parent.to_s(io) - - # Add padding between the node names - # only if the names don't appear to be symbolic. - # Skip blank group names (like the root group). - io << ' ' unless !parent.name? || # ameba:disable Style/NegatedConditionsInUnless - (parent.name?.is_a?(Symbol) && name.is_a?(String) && - (name.starts_with?('#') || name.starts_with?('.'))) - end + # Add padding between the node names + # only if the names don't appear to be symbolic. + # Skip blank group names (like the root group). + io << ' ' unless !parent.name? || # ameba:disable Style/NegatedConditionsInUnless + (parent.name?.is_a?(Symbol) && name.is_a?(String) && + (name.starts_with?('#') || name.starts_with?('.'))) super end