Class: TestLauncher::Frameworks::Implementation::Consolidator
- Inherits:
-
Struct
- Object
- Struct
- TestLauncher::Frameworks::Implementation::Consolidator
- Defined in:
- lib/test_launcher/frameworks/implementation/consolidator.rb
Instance Attribute Summary collapse
-
#run_all ⇒ Object
Returns the value of attribute run_all.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#search_results ⇒ Object
Returns the value of attribute search_results.
-
#shell ⇒ Object
Returns the value of attribute shell.
Class Method Summary collapse
Instance Method Summary collapse
- #consolidate ⇒ Object
- #examples_found? ⇒ Boolean
- #file_count ⇒ Object
- #file_count_phrase ⇒ Object
- #files_found? ⇒ Boolean
- #last_edited ⇒ Object
- #methods_count_phrase ⇒ Object
- #one_example? ⇒ Boolean
- #pluralize(count, singular) ⇒ Object
- #run_last_edited? ⇒ Boolean
- #same_file? ⇒ Boolean
Instance Attribute Details
#run_all ⇒ Object
Returns the value of attribute run_all
4 5 6 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 4 def run_all @run_all end |
#runner ⇒ Object
Returns the value of attribute runner
4 5 6 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 4 def runner @runner end |
#search_results ⇒ Object
Returns the value of attribute search_results
4 5 6 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 4 def search_results @search_results end |
#shell ⇒ Object
Returns the value of attribute shell
4 5 6 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 4 def shell @shell end |
Class Method Details
.consolidate(*args) ⇒ Object
6 7 8 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 6 def self.consolidate(*args) new(*args).consolidate end |
Instance Method Details
#consolidate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 10 def consolidate if search_results.empty? nil elsif one_example? shell.notify "Found #{methods_count_phrase} in #{file_count_phrase}." runner.single_example(search_results.first) elsif examples_found? && same_file? shell.notify "Multiple test methods match in 1 file." runner.single_example(search_results.first) elsif examples_found? && run_last_edited? shell.notify "Found #{methods_count_phrase} in #{file_count_phrase}." shell.notify "Running most recently edited. Run with '--all' to run all the tests." runner.single_example(last_edited) elsif files_found? && same_file? shell.notify "Found #{file_count_phrase}." runner.single_file(search_results.first) elsif files_found? && run_last_edited? shell.notify "Found #{file_count_phrase}." shell.notify "Running most recently edited. Run with '--all' to run all the tests." runner.single_file(last_edited) else shell.notify "Found #{file_count_phrase}." runner.multiple_files(search_results.uniq {|sr| sr.file}) end end |
#examples_found? ⇒ Boolean
44 45 46 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 44 def examples_found? search_results.examples_found? end |
#file_count ⇒ Object
60 61 62 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 60 def file_count search_results.file_count end |
#file_count_phrase ⇒ Object
68 69 70 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 68 def file_count_phrase pluralize(file_count, "file") end |
#files_found? ⇒ Boolean
48 49 50 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 48 def files_found? ! examples_found? end |
#last_edited ⇒ Object
56 57 58 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 56 def last_edited search_results.last_edited end |
#methods_count_phrase ⇒ Object
64 65 66 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 64 def methods_count_phrase pluralize(search_results.size, "test method") end |
#one_example? ⇒ Boolean
40 41 42 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 40 def one_example? search_results.one_example? end |
#pluralize(count, singular) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 72 def pluralize(count, singular) phrase = "#{count} #{singular}" if count == 1 phrase else "#{phrase}s" end end |
#run_last_edited? ⇒ Boolean
52 53 54 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 52 def run_last_edited? ! run_all end |
#same_file? ⇒ Boolean
36 37 38 |
# File 'lib/test_launcher/frameworks/implementation/consolidator.rb', line 36 def same_file? file_count == 1 end |