Module: SimpleCov::Combine::ResultsCombiner
| Relationships & Source Files | |
| Defined in: | lib/simplecov/combine/results_combiner.rb |
Overview
There might be reports from different kinds of tests, e.g. RSpec and Cucumber. We need to combine their results into unified one. This class does that. To unite the results on file basis, it leverages the combine of lines and branches inside each file within given results.
Class Method Summary
-
.combine(*results) ⇒ Hash
mod_func
::SimpleCov::Combineprocess explanation => ResultCombiner: define all present files between results and start combine on file level. -
.combine_file_coverage(coverage_a, coverage_b) ⇒ Hash
mod_func
::SimpleCov::Combinetwo files coverage results. -
.combine_result_sets(combined_results, result) ⇒ Hash
mod_func
Manage combining results on files level.
Class Method Details
.combine(*results) ⇒ Hash (mod_func)
::SimpleCov::Combine process explanation
> ResultCombiner: define all present files between results and start combine on file level.
> FileCombiner: collect result of next combine levels lines, branches, and methods.
> LinesCombiner: combine lines results.
> BranchesCombiner: combine branches results.
> MethodsCombiner: combine methods results.
# File 'lib/simplecov/combine/results_combiner.rb', line 23
def combine(*results) results.reduce({}) do |combined_results, next_result| combine_result_sets(combined_results, next_result) end end
.combine_file_coverage(coverage_a, coverage_b) ⇒ Hash (mod_func)
::SimpleCov::Combine two files coverage results
# File 'lib/simplecov/combine/results_combiner.rb', line 56
def combine_file_coverage(coverage_a, coverage_b) Combine.combine(Combine::FilesCombiner, coverage_a, coverage_b) end
.combine_result_sets(combined_results, result) ⇒ Hash (mod_func)
Manage combining results on files level
# File 'lib/simplecov/combine/results_combiner.rb', line 37
def combine_result_sets(combined_results, result) results_files = combined_results.keys | result.keys results_files.to_h do |file_name| [file_name, combine_file_coverage( combined_results[file_name], result[file_name] )] end end