Class: M::Executor
- Inherits:
-
Object
- Object
- M::Executor
- Defined in:
- lib/m/executor.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(testable) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(testable) ⇒ Executor
Returns a new instance of Executor.
9 10 11 |
# File 'lib/m/executor.rb', line 9 def initialize testable @testable = testable end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/m/executor.rb', line 13 def execute # Locate tests to run that may be inside of this line. There could be more than one! tests_to_run = tests.within testable.lines # If we found any tests, if tests_to_run.size.positive? # assemble the regexp to run these tests, test_names = tests_to_run.map { |test| Regexp.escape(test.name) }.join("|") # set up the args needed for the runner test_arguments = ["-n", "/^(#{test_names})$/"] # directly run the tests from here and exit with the status of the tests passing or failing runner.run test_arguments + testable. elsif tests.size.positive? # Otherwise we found no tests on this line, so you need to pick one. = "No tests found on line #{testable.lines.join ", "}. Valid tests to run:\n\n" # For every test ordered by line number, # spit out the test name and line number where it starts, tests.by_line_number do |test| << "#{format "%0#{tests.column_size}s", test.name}: m #{testable.file}:#{test.start_line}\n" end # Spit out helpful message and bail warn false else # There were no tests at all = "There were no tests found.\n\n" warn false end end |