Skip to content

Commit 0e719e1

Browse files
committed
Add comments and appease RuboCop
1 parent 2368499 commit 0e719e1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

spec/spec_helper.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ def self.run_all(reporter = nil)
5252
config.warnings = true
5353
config.raise_on_warning = true
5454

55+
# Execute a provided block with RSpec global objects (configuration,
56+
# world, current example) reset. This is used to test specs with RSpec.
5557
config.around(:example) do |example|
56-
RSpec::Core::Sandbox.sandboxed do |config|
57-
RSpec::Rails.initialize_configuration(config)
58+
# If there is an example-within-an-example, we want to make sure the inner
59+
# example does not get a reference to the outer example (the real spec) if
60+
# it calls something like `pending`.
61+
RSpec::Core::Sandbox.sandboxed do |sandbox_config|
62+
sandbox_config.before(:context) { RSpec.current_example = nil }
63+
RSpec::Rails.initialize_configuration(sandbox_config)
5864
example.run
5965
end
6066
end

0 commit comments

Comments
 (0)