Class: TestLauncher::Queries::MultiExampleNameQuery
- Inherits:
-
BaseQuery
- Object
- BaseQuery
- TestLauncher::Queries::MultiExampleNameQuery
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
Instance Method Details
#command ⇒ Object
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
# File 'lib/test_launcher/queries.rb', line 292
def command
return if test_cases.empty?
if one_example?
{
notifies: ["Found 1 example in 1 file."],
command: runner.single_example(test_cases.first)
}
elsif one_file?
{
notifies: ["Found #{test_cases.size} examples in 1 file."],
command: runner.multiple_examples_same_file(test_cases) }
else
{
notifies: ["Found #{pluralize(test_cases.size, "example")} in #{pluralize(file_count, "file")}."],
command: runner.multiple_examples(test_cases)
}
end
end
|
#examples_found ⇒ Object
326
327
328
|
# File 'lib/test_launcher/queries.rb', line 326
def examples_found
@examples_found_by_joining_query ||= searcher.examples(joined_query)
end
|
#joined_query ⇒ Object
330
331
332
|
# File 'lib/test_launcher/queries.rb', line 330
def joined_query
@joined_query ||= request.search_string.squeeze(" ").gsub(" ", "|")
end
|
#one_example? ⇒ Boolean
334
335
336
|
# File 'lib/test_launcher/queries.rb', line 334
def one_example?
test_cases.size == 1
end
|
#test_cases ⇒ Object
313
314
315
316
317
318
319
320
321
322
323
324
|
# File 'lib/test_launcher/queries.rb', line 313
def test_cases
return [] if joined_query == request.search_string
@test_cases_found_by_joining_query ||= examples_found.map { |grep_result|
request.test_case(
file: grep_result[:file],
example: joined_query,
line_number: grep_result[:line_number],
request: request
)
}
end
|