class KnapsackPro::TestCaseMergers::RSpecMerger
Public Instance Methods
Source
# File lib/knapsack_pro/test_case_mergers/rspec_merger.rb, line 6 def call all_test_files_hash = {} merged_test_file_examples_hash = {} test_files.each do |test_file| path = test_file.fetch('path') test_file_path = extract_test_file_path(path) if KnapsackPro::Adapters::RSpecAdapter.id_path?(path) merged_test_file_examples_hash[test_file_path] ||= 0.0 merged_test_file_examples_hash[test_file_path] += test_file.fetch('time_execution') else all_test_files_hash[test_file_path] = test_file.fetch('time_execution') end end merged_test_file_examples_hash.each do |path, time_execution| all_test_files_hash[path] = [time_execution, all_test_files_hash[path]].compact.max end merged_test_files = [] all_test_files_hash.each do |path, time_execution| merged_test_files << { 'path' => path, 'time_execution' => time_execution } end merged_test_files end
Private Instance Methods
Source
# File lib/knapsack_pro/test_case_mergers/rspec_merger.rb, line 41 def extract_test_file_path(path) path.gsub(/\.rb\[.+\]$/, '.rb') end
path - can be: test file path: spec/a_spec.rb or test example path: spec/a_spec.rb