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.
# 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