Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.