class Dockerspec::EngineList

Manages the list of testing engines to use.

Constants

NO_ENGINES_MESSAGE

A message with description on how to avoid the error when you forget specifying the testing engine you want to use.

Public Class Methods

new(runner) click to toggle source

Constructs the list of engines.

Initializes all the selected engines.

@param runner [Dockerspec::Runner::Base] The class used to run the

docker container.

@return [Dockerspec::EngineList] The list of engines.

@raise [Dockerspec::EngineError] Raises this exception when the engine

list is empty.

@api public

# File lib/dockerspec/engine_list.rb, line 58
def initialize(runner)
  engine_classes = Configuration.engines
  @engines =
    engine_classes.map { |engine_class| engine_class.new(runner) }
  assert_engines!
end

Public Instance Methods

before_running(*args) click to toggle source

Setups all the engines one by one.

@param args [Mixed] Arguments to pass to the `#before_running` methods.

@return void

@api public

# File lib/dockerspec/engine_list.rb, line 74
def before_running(*args)
  call_engines_method(:before_running, *args)
end
restore(*args) click to toggle source

Restores all the engines one by one.

@param args [Mixed] Arguments to pass to the `#restore` methods.

@return void

@api public

# File lib/dockerspec/engine_list.rb, line 114
def restore(*args)
  call_engines_method(:restore, *args)
end
when_container_ready(*args) click to toggle source

Notify the engines that the container to test is selected and ready.

@param args [Mixed] Arguments to pass to the `#when_container_ready` methods.

@return void

@api public

# File lib/dockerspec/engine_list.rb, line 88
def when_container_ready(*args)
  call_engines_method(:when_container_ready, *args)
end
when_running(*args) click to toggle source

Saves all the engines one by one.

@param args [Mixed] Arguments to pass to the `#when_running` methods.

@return void

@api public

# File lib/dockerspec/engine_list.rb, line 101
def when_running(*args)
  call_engines_method(:when_running, *args)
end

Protected Instance Methods

assert_engines!() click to toggle source

Ensures that there has been chosen at least one engine.

@return void

@raise [Dockerspec::EngineError] Raises this exception when the engine

list is empty.

@api private

# File lib/dockerspec/engine_list.rb, line 130
def assert_engines!
  return unless @engines.empty?
  raise EngineError, NO_ENGINES_MESSAGE
end
call_engines_method(method, *args) click to toggle source

Runs the same method on all the engines.

@param method [String, Symbol] The method to run.

@param args [Mixed] Arguments to pass to the methods.

@return void

@api private

# File lib/dockerspec/engine_list.rb, line 146
def call_engines_method(method, *args)
  @engines.map { |engine| engine.send(method, *args) }
end