Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 86362bf

Browse files
committed
Move group global hook registration into configure_group.
This ensures that if we need to re-configure a group hooks registration happens appropriately. Also, do the same for example configuration.
1 parent 6e5a48f commit 86362bf

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/rspec/core/configuration.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,8 @@ def prepend(mod, *filters)
13041304
# Used internally to extend a group with modules using `include`, `prepend` and/or
13051305
# `extend`.
13061306
def configure_group(group)
1307+
group.hooks.register_globals(group, hooks)
1308+
13071309
configure_group_with group, @include_modules, :safe_include
13081310
configure_group_with group, @extend_modules, :safe_extend
13091311
configure_group_with group, @prepend_modules, :safe_prepend
@@ -1313,7 +1315,8 @@ def configure_group(group)
13131315
#
13141316
# Used internally to extend the singleton class of a single example's
13151317
# example group instance with modules using `include` and/or `extend`.
1316-
def configure_example(example)
1318+
def configure_example(example, example_hooks)
1319+
example_hooks.register_global_singleton_context_hooks(example, hooks)
13171320
singleton_group = example.example_group_instance.singleton_class
13181321

13191322
# We replace the metadata so that SharedExampleGroupModule#included

lib/rspec/core/example.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ def example_group
229229
def run(example_group_instance, reporter)
230230
@example_group_instance = example_group_instance
231231
@reporter = reporter
232-
hooks.register_global_singleton_context_hooks(self, RSpec.configuration.hooks)
233-
RSpec.configuration.configure_example(self)
232+
RSpec.configuration.configure_example(self, hooks)
234233
RSpec.current_example = self
235234

236235
start(reporter)

lib/rspec/core/example_group.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ def self.set_it_up(description, args, registration_collection, &example_group_bl
426426

427427
@currently_executing_a_context_hook = false
428428

429-
hooks.register_globals(self, RSpec.configuration.hooks)
430429
RSpec.configuration.configure_group(self)
431430
end
432431

0 commit comments

Comments
 (0)