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
Is your feature request related to a problem? Please describe.
It's really difficult to integrate the capybara-screenshot gem with rails system specs. (see mattheworiordan/capybara-screenshot#225), but I think there is a generic issue for other libraries and integrations that you want the resetting of capybara sessions to happen as late as possible (and critically, after all RSpec Notifiers have formatted their output).
The minitest after_teardown callback occurs during the after hooks in the lifecycle of system specs, but occurs after all the after hooks (after example.run during the around) in all other specs.
The after_teardown is where the Capybara.reset_sessions! happens and (as of Rails 6.0) the take_screenshot occurs occurs during before_teardown/
Describe the solution you'd like
I'd like the after_teardown to happen during an around callback.
This wouldn't be possible if rspec-rails was still supporting Rails v5.2
This may change behaviour for downstream users, but should be able to be included in 6 because a major•revision with an appropriate warning in the changelog?
I'll do a possible implementation/illustration in a PR.
Describe alternatives you've considered
I've considered whether this should be an adaptation of rails (I don't think there's any argument for changing rails).
I've considered if this should be an adaptation of downstream libraries such as capybara-screenshot (see mattheworiordan/capybara-screenshot#225, this seems tricky to do -- though this may be down to architectural decisions in capybara-screenshot).
I've also attempted to monkey-patch either the rails ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown class in an ad hoc way in my own rails projects but this is quite difficult to do because it is already heavily monkey-patched by RSpec::Rails::SystemExampleGroup.
Additional context
I will raise this in rspec@googlegroups.com, but I think it's probably easier to see as set out in this issue.
The text was updated successfully, but these errors were encountered:
timdiggins
added a commit
to timdiggins/rspec-rails
that referenced
this issue
Apr 22, 2022
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) rspec#2595
Is your feature request related to a problem? Please describe.
It's really difficult to integrate the capybara-screenshot gem with rails system specs. (see mattheworiordan/capybara-screenshot#225), but I think there is a generic issue for other libraries and integrations that you want the resetting of capybara sessions to happen as late as possible (and critically, after all RSpec Notifiers have formatted their output).
The minitest
after_teardown
callback occurs during theafter
hooks in the lifecycle of system specs, but occurs after all theafter
hooks (after example.run during thearound
) in all other specs.rspec-rails/lib/rspec/rails/adapters.rb
Lines 69 to 78 in 9fb6c9c
rspec-rails/lib/rspec/rails/example/system_example_group.rb
Lines 103 to 116 in 9fb6c9c
The
after_teardown
is where theCapybara.reset_sessions!
happens and (as of Rails 6.0) the take_screenshot occurs occurs during before_teardown/Describe the solution you'd like
I'd like the after_teardown to happen during an around callback.
This wouldn't be possible if rspec-rails was still supporting Rails v5.2
This may change behaviour for downstream users, but should be able to be included in 6 because a major•revision with an appropriate warning in the changelog?
I'll do a possible implementation/illustration in a PR.
Describe alternatives you've considered
I've considered whether this should be an adaptation of rails (I don't think there's any argument for changing rails).
I've considered if this should be an adaptation of downstream libraries such as capybara-screenshot (see mattheworiordan/capybara-screenshot#225, this seems tricky to do -- though this may be down to architectural decisions in capybara-screenshot).
I've also attempted to monkey-patch either the rails
ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
class in an ad hoc way in my own rails projects but this is quite difficult to do because it is already heavily monkey-patched byRSpec::Rails::SystemExampleGroup
.Additional context
I will raise this in rspec@googlegroups.com, but I think it's probably easier to see as set out in this issue.
The text was updated successfully, but these errors were encountered: