Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated currently_executing_a_context_hook? #2911

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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