Skip to content

Commit

Permalink
run after_teardown in system specs after around (like inm other specs)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
timdiggins committed Apr 22, 2022
1 parent 6f8e3ab commit 72df7f1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/rspec/rails/example/system_example_group.rb
Expand Up @@ -108,17 +108,19 @@ def driven_by(driver, **driver_options, &blk)
orig_stdout = $stdout
$stdout = StringIO.new
begin
if ::Rails::VERSION::STRING >= '6.0'
original_before_teardown.bind(self).call
end
original_after_teardown.bind(self).call
original_before_teardown.bind(self).call
ensure
myio = $stdout
myio.rewind
RSpec.current_example.metadata[:extra_failure_lines] = myio.readlines
$stdout = orig_stdout
end
end

around do |example|
example.run
original_after_teardown.bind(self).call
end
end
end
end
Expand Down

0 comments on commit 72df7f1

Please sign in to comment.