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

View file

@ -4,53 +4,40 @@ module Spectator
class NestedExampleGroup < ExampleGroup class NestedExampleGroup < ExampleGroup
getter what : String getter what : String
getter! parent : ExampleGroup getter parent : ExampleGroup
def initialize(@what, @parent, hooks : ExampleHooks) def initialize(@what, @parent, hooks : ExampleHooks)
super(hooks) super(hooks)
end end
def run_before_all_hooks : Nil def run_before_all_hooks : Nil
if (parent = @parent)
parent.run_before_all_hooks parent.run_before_all_hooks
end
super super
end end
def run_before_each_hooks : Nil def run_before_each_hooks : Nil
if (parent = @parent)
parent.run_before_each_hooks parent.run_before_each_hooks
end
super super
end end
def run_after_all_hooks : Nil def run_after_all_hooks : Nil
super super
if (parent = @parent)
parent.run_after_all_hooks parent.run_after_all_hooks
end end
end
def run_after_each_hooks : Nil def run_after_each_hooks : Nil
super super
if (parent = @parent)
parent.run_after_each_hooks parent.run_after_each_hooks
end end
end
def wrap_around_each_hooks(&block : ->) : -> def wrap_around_each_hooks(&block : ->) : ->
super(&block).tap do |wrapper| wrapper = super(&block)
if (parent = @parent) parent.wrap_around_each_hooks(&wrapper)
wrapper = parent.wrap_around_each_hooks(&wrapper)
end
end
end end
def to_s(io) def to_s(io)
if (parent = @parent)
parent.to_s(io) parent.to_s(io)
io << ' ' io << ' '
end
io << what io << what
end end
end end