From 718e2c026a7892d44152ab5edacc4d5f0c462c1e Mon Sep 17 00:00:00 2001 From: Holger Just Date: Thu, 23 Jul 2020 16:29:34 +0200 Subject: [PATCH] Create an lcov file for coverage instead of the automatic simplecov formatter for coveralls --- Gemfile | 6 +++++- spec/spec_helper.rb | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 4ca57e1..93ec869 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,11 @@ gem 'rake' group :test do gem 'rspec', '~> 3.0' - gem 'coveralls', '~> 0.8.20' + + if Gem.ruby_version >= Gem::Version.new('2.4.0') + gem 'simplecov', '~> 0.18' + gem 'simplecov-lcov', '~> 0.8' + end gem 'rack', ENV['RACK_VERSION'] ? "~> #{ENV['RACK_VERSION']}" : nil end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dad04b4..d948db7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,13 +6,23 @@ # of the MIT license. See the LICENSE.txt file for details. if ENV['COVERAGE'].to_s == 'true' + if Gem.ruby_version <= Gem::Version.new('2.4.0') + STDERR.puts "Simplecov requires Ruby 2.4, but we are currently on " \ + "#{RUBY_VERSION}. Try running the spec again without collecting " \ + "coverage details (by leaving the COVERAGE environment variable empty) " \ + "or by using a newer Ruby version." + exit 1 + end + require 'simplecov' - if ENV['CI'] == 'true' - require 'coveralls' - SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ - SimpleCov::Formatter::HTMLFormatter, - Coveralls::SimpleCov::Formatter + if ENV['CI'].to_s == 'true' + require 'simplecov-lcov' + + SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true + SimpleCov.formatters = [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::LcovFormatter ] else SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter