Refactor: store current_example in a local.
Created by: myronmarston
- There's no need to call
RSpec.current_example
many times in this method. - This wasn't working correctly for specs that
create an example group and run it (from within
the spec itself), as that caused
RSpec.current_example
to get cleared when the locally created example group completed, even though the spec that created the example group had not yet completed. For an example of this, see this rspec-its PR:
https://github.com/rspec/rspec-its/pull/1#discussion_r6677739