@@ -1161,7 +1161,7 @@ def exclusion_filter
1161
1161
def include ( mod , *filters )
1162
1162
meta = Metadata . build_hash_from ( filters , :warn_about_example_group_filtering )
1163
1163
@include_modules . append ( mod , meta )
1164
- configure_existing_groups ( mod , meta , : safe_include)
1164
+ on_existing_matching_groups ( meta ) { | group | safe_include ( mod , group ) }
1165
1165
end
1166
1166
1167
1167
# Tells RSpec to extend example groups with `mod`. Methods defined in
@@ -1197,7 +1197,7 @@ def include(mod, *filters)
1197
1197
def extend ( mod , *filters )
1198
1198
meta = Metadata . build_hash_from ( filters , :warn_about_example_group_filtering )
1199
1199
@extend_modules . append ( mod , meta )
1200
- configure_existing_groups ( mod , meta , : safe_extend)
1200
+ on_existing_matching_groups ( meta ) { | group | safe_extend ( mod , group ) }
1201
1201
end
1202
1202
1203
1203
if RSpec ::Support ::RubyFeatures . module_prepends_supported?
@@ -1236,7 +1236,7 @@ def extend(mod, *filters)
1236
1236
def prepend ( mod , *filters )
1237
1237
meta = Metadata . build_hash_from ( filters , :warn_about_example_group_filtering )
1238
1238
@prepend_modules . append ( mod , meta )
1239
- configure_existing_groups ( mod , meta , : safe_prepend)
1239
+ on_existing_matching_groups ( meta ) { | group | safe_prepend ( mod , group ) }
1240
1240
end
1241
1241
end
1242
1242
@@ -1826,10 +1826,9 @@ def configure_group_with(group, module_list, application_method)
1826
1826
end
1827
1827
end
1828
1828
1829
- def configure_existing_groups ( mod , meta , application_method )
1829
+ def on_existing_matching_groups ( meta )
1830
1830
world . all_example_groups . each do |group |
1831
- next unless meta . empty? || MetadataFilter . apply? ( :any? , meta , group . metadata )
1832
- __send__ ( application_method , mod , group )
1831
+ yield group if meta . empty? || MetadataFilter . apply? ( :any? , meta , group . metadata )
1833
1832
end
1834
1833
end
1835
1834
0 commit comments