Skip to content

Commit 72df7f1

Browse files
committed
run after_teardown in system specs after around (like inm other specs)
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
1 parent 6f8e3ab commit 72df7f1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/rspec/rails/example/system_example_group.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,19 @@ def driven_by(driver, **driver_options, &blk)
108108
orig_stdout = $stdout
109109
$stdout = StringIO.new
110110
begin
111-
if ::Rails::VERSION::STRING >= '6.0'
112-
original_before_teardown.bind(self).call
113-
end
114-
original_after_teardown.bind(self).call
111+
original_before_teardown.bind(self).call
115112
ensure
116113
myio = $stdout
117114
myio.rewind
118115
RSpec.current_example.metadata[:extra_failure_lines] = myio.readlines
119116
$stdout = orig_stdout
120117
end
121118
end
119+
120+
around do |example|
121+
example.run
122+
original_after_teardown.bind(self).call
123+
end
122124
end
123125
end
124126
end

0 commit comments

Comments
 (0)