lib/retest/repository.rb in retest-0.3.1 vs lib/retest/repository.rb in retest-0.4.0
- old
+ new
@@ -24,17 +24,23 @@
tests[get_input]
end
end
def test_options(path)
+ return [path] if is_test_file?(path)
+
files.select { |file| regex(path) =~ file }
.sort_by { |file| String::Similarity.levenshtein(path, file) }
.last(5)
.reverse
end
def default_files
@default_files ||= Dir.glob('**/*') - Dir.glob('{tmp,node_modules}/**/*')
+ end
+
+ def is_test_file?(path)
+ Regexp.new(".*(?:spec|test)#{File.extname(path)}") =~ path
end
def regex(path)
extname = File.extname(path)
basename = File.basename(path, extname)
\ No newline at end of file