Skip to content

Instantly share code, notes, and snippets.

@ktopolski
Last active June 27, 2019 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktopolski/1f7c38dcde2f4573a33ed20816b16359 to your computer and use it in GitHub Desktop.
Save ktopolski/1f7c38dcde2f4573a33ed20816b16359 to your computer and use it in GitHub Desktop.
merge simplecov results
require 'json'
require 'simplecov'
Dir["coverage/.resultset-*.json"]
.map(&File.method(:read))
.map(&JSON.method(:parse))
.map { |json| SimpleCov::Result.new(json['RSpec']['coverage']) }
.then { |results| SimpleCov::ResultMerger.merge_results(*results) }
.then { |merged_result| merged_result.covered_percent < 100 }
# or, ruby 2.6 proc composition style
json_to_simplecov_result = -> (json) { SimpleCov::Result.new(json['RSpec']['coverage']) }
transform_result_json = File.method(:read) >> JSON.method(:parse) >> json_to_simplecov_result
Dir["coverage/.resultset-*.json"]
.map(&transform_result_json)
.then { |results| SimpleCov::ResultMerger.merge_results(*results) }
.then { |merged_result| merged_result.covered_percent < 100 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment