-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
Adds RSpec.current_example
#1004
Conversation
Updated the commit message to say 2.99 and 3.0. 2.14 isn't relevant here. My mistake originally. |
I think we will want to backport this to 2.99, but not 2.14. |
Yeah we'd need to backport this to |
@@ -490,8 +482,11 @@ def instance_exec_with_rescue(example, context = nil, &hook) | |||
begin | |||
instance_exec(example, &hook) | |||
rescue Exception => e | |||
raise unless @_current_rspec_example | |||
@_current_rspec_example.set_exception(e, context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I preferred the previous format...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aw, really? :) Why is that? I found the explicit conditional easier to parse in my mind. That said, I'm willing to be convinced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentally parse it as "we must error unless we have an example to set the exception on"
* Library authors that want to support RSpec 2 and 3 can use `RSpec.current_example` to find the current example in a hook method. In RSpec versions before 2.99, `self.example` can be used (but `self.example` is deprecated in RSpec >= 2.99 and removed in RSpec 3).
* While RSpec isn't necessarily thread safe right now, it might be in the future.
Ready for re-review: |
LGTM. Merge when green. |
Adds `RSpec.current_example`
can use
RSpec.current_example
to find the current example in a hookmethod. In RSpec versions before 2.99,
self.example
can be used (butself.example
is deprecated in RSpec >= 2.99 and removed in RSpec 3).