Class: KnapsackPro::TestCaseMergers::RSpecMerger
- Inherits:
-
Object
- Object
- KnapsackPro::TestCaseMergers::RSpecMerger
- Defined in:
- lib/knapsack_pro/test_case_mergers/rspec_merger.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(test_files) ⇒ RSpecMerger
constructor
A new instance of RSpecMerger.
Constructor Details
#initialize(test_files) ⇒ RSpecMerger
Returns a new instance of RSpecMerger.
6 7 8 |
# File 'lib/knapsack_pro/test_case_mergers/rspec_merger.rb', line 6 def initialize(test_files) @test_files = test_files end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/knapsack_pro/test_case_mergers/rspec_merger.rb', line 10 def call file_paths = {} id_paths = {} @test_files.each do |test_file| raw_path = test_file.fetch('path') file_path = KnapsackPro::Adapters::RSpecAdapter.parse_file_path(raw_path) if KnapsackPro::Adapters::RSpecAdapter.id_path?(raw_path) id_paths[file_path] ||= 0.0 id_paths[file_path] += test_file.fetch('time_execution') else file_paths[file_path] = test_file.fetch('time_execution') # may be nil end end file_paths .merge(id_paths) { |_, v1, v2| [v1, v2].compact.max } .map do |file_path, time_execution| { 'path' => file_path, 'time_execution' => time_execution } end end |