Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
Prev Previous commit
Next Next commit
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.
  • Loading branch information
myronmarston committed Jun 4, 2016
commit 86362bfcb1ab1670c486f829a438f2a3b920c890
5 changes: 4 additions & 1 deletion lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,8 @@ def prepend(mod, *filters)
# Used internally to extend a group with modules using `include`, `prepend` and/or
# `extend`.
def configure_group(group)
group.hooks.register_globals(group, hooks)

configure_group_with group, @include_modules, :safe_include
configure_group_with group, @extend_modules, :safe_extend
configure_group_with group, @prepend_modules, :safe_prepend
Expand All @@ -1313,7 +1315,8 @@ def configure_group(group)
#
# Used internally to extend the singleton class of a single example's
# example group instance with modules using `include` and/or `extend`.
def configure_example(example)
def configure_example(example, example_hooks)
example_hooks.register_global_singleton_context_hooks(example, hooks)
singleton_group = example.example_group_instance.singleton_class

# We replace the metadata so that SharedExampleGroupModule#included
Expand Down
3 changes: 1 addition & 2 deletions lib/rspec/core/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ def example_group
def run(example_group_instance, reporter)
@example_group_instance = example_group_instance
@reporter = reporter
hooks.register_global_singleton_context_hooks(self, RSpec.configuration.hooks)
RSpec.configuration.configure_example(self)
RSpec.configuration.configure_example(self, hooks)
RSpec.current_example = self

start(reporter)
Expand Down
1 change: 0 additions & 1 deletion lib/rspec/core/example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ def self.set_it_up(description, args, registration_collection, &example_group_bl

@currently_executing_a_context_hook = false

hooks.register_globals(self, RSpec.configuration.hooks)
RSpec.configuration.configure_group(self)
end

Expand Down