Skip to content

Instantly share code, notes, and snippets.

@ktopolski
Last active June 27, 2019 12:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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