Skip to content

Commit 5b6c3d6

Browse files
committed
fixup! Bring the config-level hook regression check back
1 parent 5a954dc commit 5b6c3d6

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,23 @@ def _view; end # Stub method
247247
pending_only_on_ruby_22_rails_52 = false
248248
end
249249

250-
it 'is accessible to hooks', pending: pending_only_on_ruby_22_rails_52 do
251-
group = RSpec::Core::ExampleGroup.describe 'a view', type: :view do
252-
specify { true }
253-
end
254-
run_count = 0
255-
group.before(:each) do
256-
allow(view).to receive(:render) { :value }
257-
run_count += 1
250+
# Regression test from rspec/rspec-rails#833
251+
it 'is accessible to configuration-level hooks', pending: pending_only_on_ruby_22_rails_52 do
252+
with_isolated_config do
253+
run_count = 0
254+
RSpec.configuration.before(:each, type: :view) do
255+
# `view` is provided from the view example type, and serves to
256+
# demonstrate this hook is run in the correct context.
257+
allow(view).to receive(:render) { :value }
258+
run_count += 1
259+
end
260+
group = RSpec::Core::ExampleGroup.describe 'a view', type: :view do
261+
specify { expect(view.render).to eq(:value) }
262+
end
263+
group.run(failure_reporter)
264+
expect(failure_reporter.exceptions).to eq []
265+
expect(run_count).to eq 1
258266
end
259-
group.run(failure_reporter)
260-
expect(failure_reporter.exceptions).to eq []
261-
expect(run_count).to eq 1
262267
end
263268
end
264269

0 commit comments

Comments
 (0)