Class: Kintama::Runner::Line

Inherits:
Base
  • Object
show all
Defined in:
lib/kintama/runner.rb

Overview

Runs only the test or context which contains the provided line

Instance Attribute Summary

Attributes inherited from Base

#runnables

Instance Method Summary collapse

Methods inherited from Base

#failures, #passed?, #pending, #run, #with

Constructor Details

#initialize(line) ⇒ Line

Returns a new instance of Line.


53
54
55
# File 'lib/kintama/runner.rb', line 53

def initialize(line)
  @line = line.to_i
end

Instance Method Details

#run_tests(reporter) ⇒ Object


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/kintama/runner.rb', line 57

def run_tests(reporter)
  runnable = @runnables.map { |r| r.runnable_on_line(@line) }.compact.first
  if runnable
    if runnable.is_a_test?
      hierarchy = []
      parent = runnable.parent.parent
      until parent == Kintama.default_context do
        hierarchy.unshift parent
        parent = parent.parent
      end
      hierarchy.each { |context| reporter.context_started(context) }
      runnable.parent.run_tests([runnable], false, reporter)
      hierarchy.reverse.each { |context| reporter.context_finished(context) }
      [runnable.parent]
    else
      runnable.run(reporter)
      [runnable]
    end
  else
    puts "Nothing runnable found on line #{@line}"
    exit(-1)
  end
end