Bit of cleanup around parent/group

This commit is contained in:
Michael Miller 2021-05-08 12:10:27 -06:00
parent d7ba47cc49
commit ef7fca3f95
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
2 changed files with 13 additions and 13 deletions

View file

@ -57,8 +57,8 @@ module Spectator
# The example will be assigned to *group* if it is provided. # The example will be assigned to *group* if it is provided.
# A set of *tags* can be used for filtering and modifying example behavior. # A set of *tags* can be used for filtering and modifying example behavior.
# Note: The tags will not be merged with the parent tags. # Note: The tags will not be merged with the parent tags.
def initialize(name : String? = nil, location : Location? = nil, group : ExampleGroup? = nil, def initialize(name : String? = nil, location : Location? = nil,
tags = Tags.new, &block : self ->) @group : ExampleGroup? = nil, tags = Tags.new, &block : self ->)
super(name, location, tags) super(name, location, tags)
@context = NullContext.new @context = NullContext.new
@ -85,13 +85,13 @@ module Spectator
begin begin
@result = Harness.run do @result = Harness.run do
group?.try(&.call_once_before_all) @group.try(&.call_once_before_all)
if (parent = group?) if (parent = @group)
parent.call_around_each(self) { run_internal } parent.call_around_each(self) { run_internal }
else else
run_internal run_internal
end end
if (parent = group?) if (parent = @group)
parent.call_once_after_all if parent.finished? parent.call_once_after_all if parent.finished?
end end
end end
@ -144,14 +144,14 @@ module Spectator
name = @name name = @name
# Prefix with group's full name if the node belongs to a group. # Prefix with group's full name if the node belongs to a group.
if (group = @group) if (parent = @group)
group.to_s(io) parent.to_s(io)
# Add padding between the node names # Add padding between the node names
# only if the names don't appear to be symbolic. # only if the names don't appear to be symbolic.
# Skip blank group names (like the root group). # Skip blank group names (like the root group).
io << ' ' unless !group.name? || # ameba:disable Style/NegatedConditionsInUnless io << ' ' unless !parent.name? || # ameba:disable Style/NegatedConditionsInUnless
(group.name?.is_a?(Symbol) && name.is_a?(String) && (parent.name?.is_a?(Symbol) && name.is_a?(String) &&
(name.starts_with?('#') || name.starts_with?('.'))) (name.starts_with?('#') || name.starts_with?('.')))
end end

View file

@ -124,14 +124,14 @@ module Spectator
name = @name name = @name
# Prefix with group's full name if the node belongs to a group. # Prefix with group's full name if the node belongs to a group.
if (group = @group) if (parent = @group)
group.to_s(io) parent.to_s(io)
# Add padding between the node names # Add padding between the node names
# only if the names don't appear to be symbolic. # only if the names don't appear to be symbolic.
# Skip blank group names (like the root group). # Skip blank group names (like the root group).
io << ' ' unless !group.name? || # ameba:disable Style/NegatedConditionsInUnless io << ' ' unless !parent.name? || # ameba:disable Style/NegatedConditionsInUnless
(group.name?.is_a?(Symbol) && name.is_a?(String) && (parent.name?.is_a?(Symbol) && name.is_a?(String) &&
(name.starts_with?('#') || name.starts_with?('.'))) (name.starts_with?('#') || name.starts_with?('.')))
end end