From 5e7f11547c7d294a5fc4a2359a82af9cbee8b241 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sat, 14 Aug 2021 19:30:55 +0300 Subject: [PATCH] Remove deprecated `currently_executing_a_context_hook?` --- Changelog.md | 1 + lib/rspec/core/example_group.rb | 20 ------------ spec/rspec/core/example_group_spec.rb | 46 --------------------------- 3 files changed, 1 insertion(+), 66 deletions(-) diff --git a/Changelog.md b/Changelog.md index 5a20da8f89..c66c7693a5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -33,6 +33,7 @@ Breaking Changes: (Phil Pirozhkov, #2864) * Unify multi-condition filtering to use "all" semantic. (Phil Pirozhkov, #2874) * Remove support for RR test double framework version < 3.0. (Phil Pirozhkov, #2884) +* Remove deprecated `currently_executing_a_context_hook?`. (Phil Pirozhkov, #????) Enhancements: diff --git a/lib/rspec/core/example_group.rb b/lib/rspec/core/example_group.rb index dd00a34652..2739cdbb73 100644 --- a/lib/rspec/core/example_group.rb +++ b/lib/rspec/core/example_group.rb @@ -438,8 +438,6 @@ def self.set_it_up(description, args, registration_collection, &example_group_bl ExampleGroups.assign_const(self) - @currently_executing_a_context_hook = false - config.configure_group(self) end @@ -534,30 +532,15 @@ def self.store_before_context_ivars(example_group_instance) end end - # @deprecated use `RSpec.current_scope` instead - # Returns true if a `before(:context)` or `after(:context)` - # hook is currently executing. - def self.currently_executing_a_context_hook? - RSpec.deprecate( - "currently_executing_a_context_hook", - :replacement => "RSpec.current_scope" - ) - - @currently_executing_a_context_hook - end - # @private def self.run_before_context_hooks(example_group_instance) set_ivars(example_group_instance, superclass_before_context_ivars) - @currently_executing_a_context_hook = true - ContextHookMemoized::Before.isolate_for_context_hook(example_group_instance) do hooks.run(:before, :context, example_group_instance) end ensure store_before_context_ivars(example_group_instance) - @currently_executing_a_context_hook = false end # @private @@ -569,14 +552,11 @@ def self.superclass_before_context_ivars def self.run_after_context_hooks(example_group_instance) set_ivars(example_group_instance, before_context_ivars) - @currently_executing_a_context_hook = true - ContextHookMemoized::After.isolate_for_context_hook(example_group_instance) do hooks.run(:after, :context, example_group_instance) end ensure before_context_ivars.clear - @currently_executing_a_context_hook = false end # Runs all the examples in this group. diff --git a/spec/rspec/core/example_group_spec.rb b/spec/rspec/core/example_group_spec.rb index 11f9f94ef8..0af3e99463 100644 --- a/spec/rspec/core/example_group_spec.rb +++ b/spec/rspec/core/example_group_spec.rb @@ -684,52 +684,6 @@ def define_and_run_group(define_outer_example = false) expect(order).to eq([:example, :after_example, :example, :after_example]) end - describe "#currently_executing_a_context_hook?" do - it "sets currently_executing_a_context_hook? to false initially" do - group = RSpec.describe - expect(group.currently_executing_a_context_hook?).to be false - end - - it "sets currently_executing_a_context_hook? during before(:context) execution" do - group = RSpec.describe - hook_result = nil - group.before(:context) { hook_result = group.currently_executing_a_context_hook? } - group.example("") {} - group.run - expect(hook_result).to be true - end - - it "does not set currently_executing_a_context_hook? outside of before(:context) execution" do - group = RSpec.describe - hook_result = nil - - group.before(:context) { hook_result = group.currently_executing_a_context_hook? } - group.before(:each) { hook_result = group.currently_executing_a_context_hook? } - group.example("") {} - group.run - expect(hook_result).to be false - end - - it "sets currently_executing_a_context_hook? during after(:context) execution" do - group = RSpec.describe - hook_result = nil - - group.after(:context) { hook_result = group.currently_executing_a_context_hook? } - group.example("") {} - group.run - expect(hook_result).to be true - end - - it "unsets currently_executing_a_context_hook? after an after(:context) hook is done" do - group = RSpec.describe - group.after(:context) { } - group.example("") {} - group.run - expect(group.currently_executing_a_context_hook?).to be false - end - end - end - it "runs the before alls in order" do group = RSpec.describe order = []