diff --git a/src/spectator/nested_example_group.cr b/src/spectator/nested_example_group.cr index 156708f..5f61476 100644 --- a/src/spectator/nested_example_group.cr +++ b/src/spectator/nested_example_group.cr @@ -4,53 +4,40 @@ module Spectator class NestedExampleGroup < ExampleGroup getter what : String - getter! parent : ExampleGroup + getter parent : ExampleGroup def initialize(@what, @parent, hooks : ExampleHooks) super(hooks) end def run_before_all_hooks : Nil - if (parent = @parent) - parent.run_before_all_hooks - end + parent.run_before_all_hooks super end def run_before_each_hooks : Nil - if (parent = @parent) - parent.run_before_each_hooks - end + parent.run_before_each_hooks super end def run_after_all_hooks : Nil super - if (parent = @parent) - parent.run_after_all_hooks - end + parent.run_after_all_hooks end def run_after_each_hooks : Nil super - if (parent = @parent) - parent.run_after_each_hooks - end + parent.run_after_each_hooks end def wrap_around_each_hooks(&block : ->) : -> - super(&block).tap do |wrapper| - if (parent = @parent) - wrapper = parent.wrap_around_each_hooks(&wrapper) - end - end + wrapper = super(&block) + parent.wrap_around_each_hooks(&wrapper) end def to_s(io) - if (parent = @parent) - parent.to_s(io) - io << ' ' - end + parent.to_s(io) + io << ' ' io << what end end