Class: TestLauncher::Queries::SpecifiedNameQuery

Inherits:
BaseQuery
  • Object
show all
Defined in:
lib/test_launcher/queries.rb

Instance Attribute Summary

Attributes inherited from BaseQuery

#request

Instance Method Summary collapse

Methods inherited from BaseQuery

#initialize

Constructor Details

This class inherits a constructor from TestLauncher::Queries::BaseQuery

Instance Method Details

#commandObject



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/test_launcher/queries.rb', line 116

def command
  if test_cases.empty?
    shell.warn("Could not identify file: #{request.search_string}")
  elsif test_cases.size == 1
    shell.notify("Found 1 example in 1 file.")
    runner.single_example(test_cases.first)
  else
    shell.notify "Found #{pluralize(test_cases.size, "example")} in #{pluralize(file_count, "file")}."
    shell.notify "Running most recently edited. Run with '--all' to run all the tests."
    runner.single_example(most_recently_edited_test_case)
  end
end

#potential_filesObject



139
140
141
# File 'lib/test_launcher/queries.rb', line 139

def potential_files
  @potential_files ||= searcher.test_files(request.search_string)
end

#test_casesObject



129
130
131
132
133
134
135
136
137
# File 'lib/test_launcher/queries.rb', line 129

def test_cases
  @test_cases ||= potential_files.map {|file|
    request.test_case(
      file: file,
      example: request.example_name,
      request: request,
    )
  }
end