class TestLauncher::Queries::FullRegexQuery

Public Instance Methods

command() click to toggle source
# File lib/test_launcher/queries.rb, line 305
def command
  return if test_cases.empty?

  if one_file?
    shell.notify "Found #{pluralize(file_count, "file")}."
    runner.single_file(test_cases.first)
  elsif request.run_all?
    shell.notify "Found #{pluralize(file_count, "file")}."
    runner.multiple_files(test_cases)
  else
    shell.notify "Found #{pluralize(file_count, "file")}."
    shell.notify "Running most recently edited. Run with '--all' to run all the tests."
    runner.single_file(most_recently_edited_test_case)
  end
end
files_found() click to toggle source
# File lib/test_launcher/queries.rb, line 333
def files_found
  if files_found_by_full_regex.any?
    files_found_by_full_regex
  else
    files_found_by_joining_terms
  end
end
files_found_by_full_regex() click to toggle source
# File lib/test_launcher/queries.rb, line 341
def files_found_by_full_regex
  @files_found_by_full_regex ||= searcher.grep(request.search_string)
end
files_found_by_joining_terms() click to toggle source
# File lib/test_launcher/queries.rb, line 345
def files_found_by_joining_terms
  return [] unless request.search_string.include?(" ")
  joined_query = request.search_string.squeeze(" ").gsub(" ", "|")
  @files_found_by_joining_terms ||= searcher.grep(joined_query)
end
test_cases() click to toggle source
# File lib/test_launcher/queries.rb, line 321
def test_cases
  @test_cases ||=
    files_found
      .uniq { |grep_result| grep_result[:file] }
      .map { |grep_result|
        request.test_case(
          file: grep_result[:file],
          request: request
        )
      }
end