Skip to content

Commit

Permalink
Remove deprecated currently_executing_a_context_hook?
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Aug 14, 2021
1 parent d8d985d commit 90c3062
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 65 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, #2911)

Enhancements:

Expand Down
20 changes: 0 additions & 20 deletions lib/rspec/core/example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
45 changes: 0 additions & 45 deletions spec/rspec/core/example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -683,51 +683,6 @@ def define_and_run_group(define_outer_example = false)
group.run
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
Expand Down

0 comments on commit 90c3062

Please sign in to comment.