From dcf9e2f260b13250e6db0b7845767ce054606952 Mon Sep 17 00:00:00 2001 From: Alex Robbin Date: Mon, 20 Apr 2020 10:54:03 -0400 Subject: [PATCH] indent all extra failure lines correctly in system tests If the output from Rails' system test teardown is multiple lines, we should try and render all of the lines with proper indentation. This can happen on `rails/rails@master` now that failure screenshots can include the page HTML (rails/rails@36545), and can actually happen with v6.0.2.2 if the `method_name` ends up being a little too long. --- lib/rspec/rails/example/system_example_group.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rspec/rails/example/system_example_group.rb b/lib/rspec/rails/example/system_example_group.rb index 57266d0a27..59c5606cca 100644 --- a/lib/rspec/rails/example/system_example_group.rb +++ b/lib/rspec/rails/example/system_example_group.rb @@ -114,7 +114,8 @@ def driven_by(driver, **driver_options, &blk) original_after_teardown.bind(self).call ensure myio = $stdout - RSpec.current_example.metadata[:extra_failure_lines] = myio.string + myio.rewind + RSpec.current_example.metadata[:extra_failure_lines] = myio.readlines $stdout = orig_stdout end end