Class: Dockerspec::Engine::Specinfra

Inherits:
Base
  • Object
show all
Defined in:
lib/dockerspec/engine/specinfra.rb,
lib/dockerspec/engine/specinfra/backend.rb

Overview

The Specinfra (Serverspec) testing engine implementation.

Defined Under Namespace

Classes: Backend

Instance Method Summary collapse

Methods inherited from Base

#when_container_ready

Constructor Details

#initialize(runner) ⇒ Dockerspec::Engine::Specinfra

Constructs a testing engine to use Specinfra (used by Serverspec).

Parameters:



39
40
41
42
# File 'lib/dockerspec/engine/specinfra.rb', line 39

def initialize(runner)
  super
  @backend = nil
end

Instance Method Details

#before_runningObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets the Specinfra configuration.

  • Resets the internal Specinfra backend reference.
  • Sets the chosen container name with Docker Compose.
  • Sets the :family.

Returns:

  • void



55
56
57
58
59
60
61
62
# 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

#restoreObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Returns:

  • void



86
87
88
89
90
# File 'lib/dockerspec/engine/specinfra.rb', line 86

def restore
  @backend.restore
  setup_container_name
  setup_family
end

#when_runningObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Saves the Specinfra backend reference internally to restore it later.

Returns:

  • void



71
72
73
# File 'lib/dockerspec/engine/specinfra.rb', line 71

def when_running
  @backend.save
end