-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
run after_teardown in system specs after around (like in other specs) #2596
Conversation
Might also be related to #2526, but to my understanding this change won't fix it. |
Can you write up a test for this that fails without the change? |
I think the reason (some) after hooks have no access to the page is because the reset_sessions! has already occurred. If this is the case then this would fix it. However if you are loading rspec-rails first (before requiring any other gems / adding otheer around hooks), I think that the reset_sessions should occur last (because |
Before I write this, can I try writing some pseudo code and see if this makes sense: Given: A custom (system spec only) notifier/formatter that relies on presence of capybara session If that's the kind of thing, then I could look at notifier/formatter specs for a template? @JonRowe |
I'd write a integration test that shows that the hook methods are called in the order you want to change this to, you could add a fake 3rd party module to show that is executed correctly in the sequence, but this change distills down to the order of which our hooks interact with the "test unit" hooks. |
@JonRowe Thanks for the suggestion for the approach for writing the test -- really helped. I started by writing a test that wanted the Here's my thinking:
Therefore I still want to change how the ordering of the callbacks (for 2 above). I think here it would be better if capybara-screenshot (for system specs) monkey-patched the rails take_screenshot (which it is in effect improving on) and either let rspec-rails capture output, or if it's still using a formatter. So I'll update the PR to have implement 2 above and see if it fixed the issue with capybara-screenshot. I'll get to it when I can... In the meantime (or afterwards) feedback welcome UPDATE: My bad - I based my first version of this on faulty memory. Capybara-screenshot does use an after hook so maybe changing the order will fix its integration with system specs. |
72df7f1
to
29a60c9
Compare
@JonRowe I've updated my PR as discussed with a test and a fix. It seems to fix some the integration with capybara-screenshot |
FYI I've also tested manually that:
NB with capybara-screenshot, both the capybara-screenshot and the rails mechanisms run and output their paths. I think this can be resolved (or lived with) either in capybara-screenshot, or the specific rails-app repo. One more note. It's not easily possible to backport this fix into supporting rails 5.2 while supporting the rails screenshot because this happens in the same rails callback. |
run after_teardown in system specs after around (like in other specs)
So .. has the screenshot capability really been broken since Rails 5.1 ? |
In system specs, capybara-screenshot has not been printing out screenshot locations on failure (though saving the files). Feature specs working fine. |
This will only work as expected (print out screenshot location after failed tests)
in >= rails 6.0 but 5.2 is no longer supported in main.
This may possibly change behaviour, but can be included in major
revision?
This should enable easier integration of other libraries such as
capybara-screenshot which require predictable (and late) running of
Capybara.reset_sessions!
This is an illustration (or possible candidate to fix) #2595