From 8f165d84dcf25756ca97b7953a4be7330ffe12c0 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 12 Apr 2023 22:25:31 +0100 Subject: [PATCH] Prevent warnings about encoding from preventing transfer of errors --- lib/rspec/support/spec/in_sub_process.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rspec/support/spec/in_sub_process.rb b/lib/rspec/support/spec/in_sub_process.rb index 2f5025ec..602e9fe8 100644 --- a/lib/rspec/support/spec/in_sub_process.rb +++ b/lib/rspec/support/spec/in_sub_process.rb @@ -11,6 +11,10 @@ def in_sub_process(prevent_warnings=true) # rubocop:disable Metrics/MethodLength exception_reader, exception_writer = IO.pipe result_reader, result_writer = IO.pipe + # Set binary mode to avoid errors surrounding ascii-8bit to utf-8 conversion + # this happens with warnings on rspec-rails for example + [exception_reader, exception_writer, result_reader, result_writer].each { |io| io.binmode } + pid = Process.fork do warning_preventer = $stderr = RSpec::Support::StdErrSplitter.new($stderr)