class Dockerspec::Engine::Specinfra
The Specinfra
(Serverspec) testing engine implementation.
Public Class Methods
Constructs a testing engine to use Specinfra
(used by Serverspec).
@param runner [Dockerspec::Runner::Base] The class that is being used
to run the Docker Containers.
@return [Dockerspec::Engine::Specinfra] The engine.
@api public
Dockerspec::Engine::Base::new
# File lib/dockerspec/engine/specinfra.rb, line 39 def initialize(runner) super @backend = nil end
Public Instance Methods
Sets the Specinfra
configuration.
-
Resets the internal
Specinfra
backend reference. -
Sets the chosen container name with Docker Compose.
-
Sets the `:family`.
@return void
@api private
# File lib/dockerspec/engine/specinfra.rb, line 55 def before_running if @backend.nil? @backend = Backend.new(backend_name) @backend.reset end setup_container_name setup_family end
Restores the Specinfra
backend instance to point to this object's container.
This is used to avoid Serverspec running against the previous started container if you are testing multiple containers at the same time.
@return void
@api private
# File lib/dockerspec/engine/specinfra.rb, line 86 def restore @backend.restore setup_container_name setup_family end
Saves the Specinfra
backend reference internally to restore it later.
@return void
@api private
# File lib/dockerspec/engine/specinfra.rb, line 71 def when_running @backend.save end
Protected Instance Methods
Gets the Specinfra
backend name from the runner.
@return [String] The backend name.
@api private
# File lib/dockerspec/engine/specinfra.rb, line 101 def backend_name @runner.backend_name end
Selects the container to test.
@return void
@api private
# File lib/dockerspec/engine/specinfra.rb, line 124 def setup_container_name return unless options.key?(:container) @backend.restore_container(options[:container]) end
Sets up the OS family.
@return void
@api private
# File lib/dockerspec/engine/specinfra.rb, line 112 def setup_family return unless options.key?(:family) ::Specinfra.configuration.os(family: options[:family]) end