You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require"rspec"RSpec.describe(":after hook is run anyway")dobefore(:example)doraise"in before example"endafter(:example)doraise"in after example"endexampledoraise"in example"endend
When I run rspec after_spec.rb
I see:
Failures:
1) :after hook is run anyway
Got 0 failures and 2 other errors:
1.1) Failure/Error: raise "in before example"
RuntimeError:
in before example
# ./after_spec.rb:5:in `block (2 levels) in <top (required)>'
1.2) Failure/Error: raise "in after example"
RuntimeError:
in after example
# ./after_spec.rb:9:in `block (2 levels) in <top (required)>'
Finished in 0.00562 seconds (files took 0.57673 seconds to load)
1 example, 1 failure
Expected behavior documentation
It should be documented that :after hooks are executed despite any failures or errors in the example or respective before(:example) hooks.
It should be documented that :after hooks are executed for pending examples.
Actual behavior documentation
Is silent on that.
Can you do a pull request?
Yes, but my English may need some corrections.
The text was updated successfully, but these errors were encountered:
A pending example is just a failing example thats expected to fail, feel free to add a scenario to https://relishapp.com/rspec/rspec-core/v/3-9/docs/hooks/before-and-after-hooks if you'd like to illustrate that hooks runs despite a failing example, it is kind of covered implicitly elsewhere but I agree it could be more specific.
skalee
added a commit
to skalee/rspec-core
that referenced
this issue
Feb 4, 2020
`after` blocks are run no matter if given example has succeeded or not.
This is normal behaviour, and this very commit adds a respective
Cucumber scenario.
Fixesrspec#2692.
Subject of the issue
This issue is purely about the documentation hosted on Relish.
after(:example)
hooks are executed regardless example has failed, was skipped or whatever. I am pretty convinced that this is a correct behaviour, however it does not seem to be documented in https://relishapp.com/rspec/rspec-core/v/3-9/docs, particularly not in https://relishapp.com/rspec/rspec-core/v/3-9/docs/hooks/before-and-after-hooks, nor in https://relishapp.com/rspec/rspec-core/v/3-9/docs/pending-and-skipped-examples. Same for skipped/pending specsYour environment
Steps to reproduce
Given following spec file
after_spec.rb
:When I run
rspec after_spec.rb
I see:
Expected
behaviordocumentation:after
hooks are executed despite any failures or errors in the example or respectivebefore(:example)
hooks.:after
hooks are executed for pending examples.Actual
behaviordocumentationIs silent on that.
Can you do a pull request?
Yes, but my English may need some corrections.
The text was updated successfully, but these errors were encountered: