Class: Turn::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/turn/controller.rb

Overview

Controls execution of test run.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = Turn.config) ⇒ Controller

Returns a new instance of Controller.



8
9
10
# File 'lib/turn/controller.rb', line 8

def initialize(config=Turn.config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/turn/controller.rb', line 13

def config
  @config
end

Instance Method Details

#runnerObject

Insatance of Runner, selected based on format and runmode.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/turn/controller.rb', line 36

def runner
  @runner ||= (
    require 'turn/runners/minirunner'

    case config.runmode
    when :marshal
      Turn::MiniRunner
    when :solo
      require 'turn/runners/solorunner'
      Turn::SoloRunner
    when :cross
      require 'turn/runners/crossrunner'
      Turn::CrossRunner
    else
      Turn::MiniRunner
    end
  )
end

#setupObject



29
30
31
32
33
# File 'lib/turn/controller.rb', line 29

def setup
  config.loadpath.each{ |path| $: << path } unless config.live?
  config.requires.each{ |path| require(path) }
  config.files.each{ |path| require(path) }
end

#startObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/turn/controller.rb', line 16

def start
  if config.files.empty?
    $stderr.puts "No tests."
    return
  end

  setup

  testrun = runner.new
  testrun.start
end