我有以下设置
Gemfile
gem 'simplecov', require: false
gem 'simplecov-rcov', require: falsespec_helper.rb
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start 'rails'在规范中,我要进行视图测试。
在运行测试并尝试保存rcov_result之后,我将收到以下错误:
/.rvm/gems/ruby-2.5.1/gems/simplecov-rcov-0.2.3/lib/simplecov-rcov.rb:52:in `write': "\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)有办法解决这个问题吗?
发布于 2019-11-26 11:04:59
将simplecov和simplecov gems更新为最新版本,并在测试/规范帮助程序中放置以下代码:
class SimpleCov::Formatter::RcovFormatter
def write_file(template, output_filename, binding)
rcov_result = template.result( binding )
File.open( output_filename, 'wb' ) do |file_result|
file_result.write rcov_result
end
end
end有关文件模式的更多信息:File opening mode in Ruby
https://stackoverflow.com/questions/55631720
复制相似问题