Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 6d33eaa

Browse files
authored
Merge pull request #575 from rspec/sub-process-binary
Prevent warnings about encoding from preventing transfer of errors
2 parents f5cf0d5 + 8f165d8 commit 6d33eaa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/rspec/support/spec/in_sub_process.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ def in_sub_process(prevent_warnings=true) # rubocop:disable Metrics/MethodLength
1111
exception_reader, exception_writer = IO.pipe
1212
result_reader, result_writer = IO.pipe
1313

14+
# Set binary mode to avoid errors surrounding ascii-8bit to utf-8 conversion
15+
# this happens with warnings on rspec-rails for example
16+
[exception_reader, exception_writer, result_reader, result_writer].each { |io| io.binmode }
17+
1418
pid = Process.fork do
1519
warning_preventer = $stderr = RSpec::Support::StdErrSplitter.new($stderr)
1620

0 commit comments

Comments
 (0)