Skip to content

Commit c75b172

Browse files
committed
Add historical info to avoid confusion
The example is hard to comprehend In this example, we're making sure that `view` is available in hooks. There's no big difference in globally defined hooks and local hooks, so it's not necessary to define one on the `configuration`, and thus `with_isolated_config` becomes unnecessary as well.
1 parent 1ea3f35 commit c75b172

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,18 @@ 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
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
251252
with_isolated_config do
252253
run_count = 0
253254
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.
254257
allow(view).to receive(:render) { :value }
255258
run_count += 1
256259
end
257260
group = RSpec::Core::ExampleGroup.describe 'a view', type: :view do
258-
specify { expect(true).to eq true }
261+
specify { expect(view.render).to eq(:value) }
259262
end
260263
group.run(failure_reporter)
261264
expect(failure_reporter.exceptions).to eq []

0 commit comments

Comments
 (0)