class TestRun::Tests::Minitest::Finder
Public Class Methods
find(query, searcher)
click to toggle source
# File lib/test_run/tests/minitest/finder.rb, line 8 def self.find(query, searcher) new(query, searcher).find end
Public Instance Methods
find()
click to toggle source
# File lib/test_run/tests/minitest/finder.rb, line 12 def find return tests_found_by_absolute_path if query.match(/^\//) return tests_found_by_name unless tests_found_by_name.empty? return tests_found_by_file_name unless tests_found_by_file_name.empty? return tests_found_by_full_regex unless tests_found_by_full_regex.empty? [] end
Private Instance Methods
full_regex_search(regex)
click to toggle source
# File lib/test_run/tests/minitest/finder.rb, line 44 def full_regex_search(regex) searcher.grep(regex, file_pattern: '*_test.rb') end
tests_found_by_absolute_path()
click to toggle source
# File lib/test_run/tests/minitest/finder.rb, line 26 def tests_found_by_absolute_path relative_file_path = query.sub(Dir.pwd, '').sub(/^\//, '') [ {file: relative_file_path} ] end
tests_found_by_file_name()
click to toggle source
# File lib/test_run/tests/minitest/finder.rb, line 35 def tests_found_by_file_name @tests_found_by_file_name ||= searcher.find_files(query).select { |f| f.match(/_test\.rb/) }.map {|f| {file: f} } end
tests_found_by_full_regex()
click to toggle source
# File lib/test_run/tests/minitest/finder.rb, line 39 def tests_found_by_full_regex # we ignore the matched line since we don't know what to do with it @tests_found_by_full_regex ||= full_regex_search(query).map {|t| {file: t[:file]} } end
tests_found_by_name()
click to toggle source
# File lib/test_run/tests/minitest/finder.rb, line 31 def tests_found_by_name @tests_found_by_name ||= full_regex_search("^\s*def .*#{query}.*") end