From 1f3ad9db3d9ea23a0f5c811d126718a3d01d950f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 13 Apr 2018 22:45:33 +0900 Subject: [PATCH] Save output as binary because simplecov originally reads the source file as binary https://github.com/colszowka/simplecov/blob/v0.16.1/lib/simplecov/source_file.rb#L94. This Encoding::UndefinedConversionError https://github.com/fguillen/simplecov-rcov/issues/20 is essentially caused by the mismatch of protocols between read and writes. If we always use the template encoding of views/detail.html.erb (UTF-8), it should work for many cases, but such a fix won't work for an encoding which is not compatible with UTF-8. So this patch should be the best fix for this issue. --- lib/simplecov-rcov.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/simplecov-rcov.rb b/lib/simplecov-rcov.rb index 40b6a4d..53a4722 100644 --- a/lib/simplecov-rcov.rb +++ b/lib/simplecov-rcov.rb @@ -48,7 +48,7 @@ def format( result ) def write_file(template, output_filename, binding) rcov_result = template.result( binding ) - File.open( output_filename, "w" ) do |file_result| + File.open( output_filename, "wb" ) do |file_result| file_result.write rcov_result end end