From ef7fca3f95dd84e306f9786283bde201dbc700e4 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 8 May 2021 12:10:27 -0600 Subject: [PATCH] Bit of cleanup around parent/group --- src/spectator/example.cr | 18 +++++++++--------- src/spectator/example_group.cr | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/spectator/example.cr b/src/spectator/example.cr index ac0dfa1..574a839 100644 --- a/src/spectator/example.cr +++ b/src/spectator/example.cr @@ -57,8 +57,8 @@ module Spectator # The example will be assigned to *group* if it is provided. # A set of *tags* can be used for filtering and modifying example behavior. # Note: The tags will not be merged with the parent tags. - def initialize(name : String? = nil, location : Location? = nil, group : ExampleGroup? = nil, - tags = Tags.new, &block : self ->) + def initialize(name : String? = nil, location : Location? = nil, + @group : ExampleGroup? = nil, tags = Tags.new, &block : self ->) super(name, location, tags) @context = NullContext.new @@ -85,13 +85,13 @@ module Spectator begin @result = Harness.run do - group?.try(&.call_once_before_all) - if (parent = group?) + @group.try(&.call_once_before_all) + if (parent = @group) parent.call_around_each(self) { run_internal } else run_internal end - if (parent = group?) + if (parent = @group) parent.call_once_after_all if parent.finished? end end @@ -144,14 +144,14 @@ module Spectator name = @name # Prefix with group's full name if the node belongs to a group. - if (group = @group) - group.to_s(io) + 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 !group.name? || # ameba:disable Style/NegatedConditionsInUnless - (group.name?.is_a?(Symbol) && name.is_a?(String) && + io << ' ' unless !parent.name? || # ameba:disable Style/NegatedConditionsInUnless + (parent.name?.is_a?(Symbol) && name.is_a?(String) && (name.starts_with?('#') || name.starts_with?('.'))) end diff --git a/src/spectator/example_group.cr b/src/spectator/example_group.cr index 65392e8..b1b08fe 100644 --- a/src/spectator/example_group.cr +++ b/src/spectator/example_group.cr @@ -124,14 +124,14 @@ module Spectator name = @name # Prefix with group's full name if the node belongs to a group. - if (group = @group) - group.to_s(io) + 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 !group.name? || # ameba:disable Style/NegatedConditionsInUnless - (group.name?.is_a?(Symbol) && name.is_a?(String) && + io << ' ' unless !parent.name? || # ameba:disable Style/NegatedConditionsInUnless + (parent.name?.is_a?(Symbol) && name.is_a?(String) && (name.starts_with?('#') || name.starts_with?('.'))) end