class Dockerspec::Engine::Base

A basic class with the minimal skeleton to create a Testing Engine.

Public Class Methods

new(runner) click to toggle source

Constructs the engine.

Saves the runner and the options.

@param runner [Dockerspec::Runner::Base] The class that is being used

to run the Docker Containers.

@return [Dockerspec::Engine::Base] The engine.

@api public

# File lib/dockerspec/engine/base.rb, line 43
def initialize(runner)
  @runner = runner
end

Public Instance Methods

before_running(*args) click to toggle source

Runs the engine setup just before running docker.

Also run when there is a change in the testing target like changing the container you want to run the tests into with Docker Compose.

Usually this is implemented to clean configurations from previous tests.

Does nothing by default.

@param args [Mixed] The passed arguments.

@return void

@api public

# File lib/dockerspec/engine/base.rb, line 63
def before_running(*args); end
restore(*args) click to toggle source

Restores the engine internal status after running tests on other containers.

This is used to avoid the engine running against the last started container if you are testing multiple containers at the same time.

Does nothing by default.

@param args [Mixed] The passed arguments.

@return void

@api public

# File lib/dockerspec/engine/base.rb, line 112
def restore(*args); end
when_container_ready(*args) click to toggle source

Runs when the container to test is ready.

This is mainly used with Docker Compose to know when the container to test is selected.

Without Docker Compose this is called just after calling {#when_running}.

Does nothing by default.

@param args [Mixed] The passed arguments.

@return void

@api public

# File lib/dockerspec/engine/base.rb, line 95
def when_container_ready(*args); end
when_running(*args) click to toggle source

Saves the engine status internally after starting the docker container.

Does nothing by default.

@param args [Mixed] The passed arguments.

@return void

@api public

# File lib/dockerspec/engine/base.rb, line 76
def when_running(*args); end

Protected Instance Methods

container_name() click to toggle source

Gets the Container Name.

@return [String, nil] Container name.

@raise [Dockerspec::RunnerError] When the `#container` method is no

implemented in the subclass or cannot select the container to test.

@api private

# File lib/dockerspec/engine/base.rb, line 137
def container_name
  @runner.container_name
end
ipaddress() click to toggle source

Gets the Docker Container IP address.

@return [String] IP address.

@raise [Dockerspec::RunnerError] When the `#container` method is no

implemented in the subclass or cannot select the container to test.

@api private

# File lib/dockerspec/engine/base.rb, line 151
def ipaddress
  @runner.ipaddress
end
options() click to toggle source

Gets the configuration options from the runner.

@return [Hash] Options list.

@api private

# File lib/dockerspec/engine/base.rb, line 123
def options
  @runner.options
end