1

I have the following setup

Gemfile

  gem 'simplecov', require: false
  gem 'simplecov-rcov', require: false

spec_helper.rb

SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start 'rails'

In the specs I have tests for views.

After the tests are run and rcov tries to save the rcov_result I receive the following error:

/.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)

Is there a way to solve this?

mmsilviu
  • 1,211
  • 15
  • 25

1 Answers1

1

Update the simplecov and simplecov-rcov gems to the latest versions and place the following code in your test/spec-helpers:

   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

More information here on files modes: File opening mode in Ruby

Steve
  • 117
  • 1
  • 10
Akshay Kumar
  • 160
  • 7