Parent group can't be nil for nested group

This commit is contained in:
Michael Miller 2018-10-14 18:00:55 -06:00
parent ab146c88c2
commit 1a2cba79fc
1 changed files with 9 additions and 22 deletions

View File

@ -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