lib/retest/repository.rb in retest-1.12.0 vs lib/retest/repository.rb in retest-1.13.0

- old
+ new

@@ -10,12 +10,18 @@ def find_test(path) return unless path return if path.empty? - @path = path - cache[@path] ||= select_from MatchingOptions.for(@path, files: files) + unless cache.key?(path) + ok_to_cache, test_file = select_from path, MatchingOptions.for(path, files: files) + if ok_to_cache + cache[path] = test_file + end + end + + cache[path] end def find_tests(paths) paths .select { |path| Regexp.new("\.rb$") =~ path } @@ -47,15 +53,17 @@ end end private - def select_from(tests) - case tests.count - when 0, 1 - tests.first + def select_from(path, matching_tests) + case matching_tests.count + when 0 + [false, nil] + when 1 + [true, matching_tests.first] else - prompt.ask_which_test_to_use(@path, tests) + [true, prompt.ask_which_test_to_use(path, matching_tests)] end end end end \ No newline at end of file