@@ -1570,8 +1570,9 @@ def apply_derived_metadata_to(metadata)
1570
1570
# @see #after
1571
1571
# @see #append_after
1572
1572
def before ( scope = nil , *meta , &block )
1573
- handle_suite_hook ( scope , meta , @before_suite_hooks , :push ,
1574
- Hooks ::BeforeHook , block ) || super ( scope , *meta , &block )
1573
+ handle_suite_hook ( scope , meta ) do
1574
+ @before_suite_hooks << Hooks ::BeforeHook . new ( block , { } )
1575
+ end || super ( scope , *meta , &block )
1575
1576
end
1576
1577
alias_method :append_before , :before
1577
1578
@@ -1589,8 +1590,9 @@ def before(scope=nil, *meta, &block)
1589
1590
# @see #after
1590
1591
# @see #append_after
1591
1592
def prepend_before ( scope = nil , *meta , &block )
1592
- handle_suite_hook ( scope , meta , @before_suite_hooks , :unshift ,
1593
- Hooks ::BeforeHook , block ) || super ( scope , *meta , &block )
1593
+ handle_suite_hook ( scope , meta ) do
1594
+ @before_suite_hooks . unshift Hooks ::BeforeHook . new ( block , { } )
1595
+ end || super ( scope , *meta , &block )
1594
1596
end
1595
1597
1596
1598
# Defines a `after` hook. See {Hooks#after} for full docs.
@@ -1603,8 +1605,9 @@ def prepend_before(scope=nil, *meta, &block)
1603
1605
# @see #before
1604
1606
# @see #prepend_before
1605
1607
def after ( scope = nil , *meta , &block )
1606
- handle_suite_hook ( scope , meta , @after_suite_hooks , :unshift ,
1607
- Hooks ::AfterHook , block ) || super ( scope , *meta , &block )
1608
+ handle_suite_hook ( scope , meta ) do
1609
+ @after_suite_hooks . unshift Hooks ::AfterHook . new ( block , { } )
1610
+ end || super ( scope , *meta , &block )
1608
1611
end
1609
1612
alias_method :prepend_after , :after
1610
1613
@@ -1622,8 +1625,9 @@ def after(scope=nil, *meta, &block)
1622
1625
# @see #before
1623
1626
# @see #prepend_before
1624
1627
def append_after ( scope = nil , *meta , &block )
1625
- handle_suite_hook ( scope , meta , @after_suite_hooks , :push ,
1626
- Hooks ::AfterHook , block ) || super ( scope , *meta , &block )
1628
+ handle_suite_hook ( scope , meta ) do
1629
+ @after_suite_hooks << Hooks ::AfterHook . new ( block , { } )
1630
+ end || super ( scope , *meta , &block )
1627
1631
end
1628
1632
1629
1633
# @private
@@ -1660,7 +1664,7 @@ def on_example_group_definition_callbacks
1660
1664
1661
1665
private
1662
1666
1663
- def handle_suite_hook ( scope , meta , collection , append_or_prepend , hook_type , block )
1667
+ def handle_suite_hook ( scope , meta )
1664
1668
return nil unless scope == :suite
1665
1669
1666
1670
unless meta . empty?
@@ -1672,7 +1676,7 @@ def handle_suite_hook(scope, meta, collection, append_or_prepend, hook_type, blo
1672
1676
"The metadata you have provided (#{ meta . inspect } ) will be ignored."
1673
1677
end
1674
1678
1675
- collection . __send__ ( append_or_prepend , hook_type . new ( block , { } ) )
1679
+ yield
1676
1680
end
1677
1681
1678
1682
def run_hooks_with ( hooks , hook_context )
0 commit comments