Fix '<anonymous>' showing up for root group

This commit is contained in:
Michael Miller 2021-05-16 19:37:45 -06:00
parent 84ac41967b
commit aee171656a
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -121,19 +121,18 @@ module Spectator
# Constructs the full name or description of the example group. # Constructs the full name or description of the example group.
# This prepends names of groups this group is part of. # This prepends names of groups this group is part of.
def to_s(io) 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 name = @name
# Prefix with group's full name if the node belongs to a group. # Add padding between the node names
if (parent = @group) # only if the names don't appear to be symbolic.
parent.to_s(io) # Skip blank group names (like the root group).
io << ' ' unless !parent.name? || # ameba:disable Style/NegatedConditionsInUnless
# Add padding between the node names (parent.name?.is_a?(Symbol) && name.is_a?(String) &&
# only if the names don't appear to be symbolic. (name.starts_with?('#') || name.starts_with?('.')))
# 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
super super
end end