Class: Wukong::SpecHelpers::UnitTestRunner

Inherits:
Local::LocalRunner show all
Defined in:
lib/wukong/spec_helpers/unit_tests/unit_test_runner.rb

Overview

A class for controlling the Wukong boot sequence from within unit tests.

Subclasses the Wukong::Local::LocalRunner with which it shares most of its behavior:

  • Initialization is slightly different, to allow for each separate unit test in a suite to use a different Configliere::Param object for settings

  • The driver is the UnitTestDriver instead of the usual driver to allow for easily passing in records and getting them back out

  • The run method is a no-op so that control flow will exit out of the unit test back into the test suite

Instance Attribute Summary collapse

Attributes inherited from Runner

#settings

Instance Method Summary collapse

Methods inherited from Local::LocalRunner

#setup, #validate

Methods included from Logging

included

Methods inherited from Runner

#args, #dataflow?, #dataflow_class_for, description, #description, die, #processor?, #program_name, #program_name=, #registered?, #root, run, usage, #usage

Methods included from Runner::BootSequence

#boot!

Methods included from Runner::HelpMessage

#dump_help, #dump_help_and_exit!, #help_given?, #strip_help_param!

Methods included from Runner::DeployPackLoader

#deploy_pack_dir, #environment_file, #in_deploy_pack?, #load_deploy_pack, #loaded_deploy_pack?

Constructor Details

#initialize(label, settings) ⇒ UnitTestRunner

Initialize a new UnitTestRunner for the processor with the given label and settings.

Parameters:

  • label (Symbol)
  • settings (Hash)


31
32
33
34
35
36
37
# File 'lib/wukong/spec_helpers/unit_tests/unit_test_runner.rb', line 31

def initialize label, settings
  self.processor = label
  params = Configliere::Param.new
  params.use(:commandline)
  params.merge!(settings)
  super(params)
end

Instance Attribute Details

#processorObject

The processor this runner will create in the same way as wu-local.



24
25
26
# File 'lib/wukong/spec_helpers/unit_tests/unit_test_runner.rb', line 24

def processor
  @processor
end

Instance Method Details

#driverUnitTestDriver

Override the LocalDriver with the UnitTestDriver so we can more easily pass in and retrieve processed records.

Returns:



43
44
45
# File 'lib/wukong/spec_helpers/unit_tests/unit_test_runner.rb', line 43

def driver
  @driver ||= UnitTestDriver.new(processor, settings)
end

#load_argsObject

No need to load commandline arguments when we are testing There are other mechanisms for passing them in, plus RSpec goes into an infinite loop if you load a spec file from within a spec file



51
52
# File 'lib/wukong/spec_helpers/unit_tests/unit_test_runner.rb', line 51

def load_args
end

#runObject

Do nothing. This prevents control flow within the Ruby interpreter from staying within this runner, as it would ordinarly do for wu-local.



57
58
# File 'lib/wukong/spec_helpers/unit_tests/unit_test_runner.rb', line 57

def run
end