Class: Dockerspec::Serverspec::SpecinfraBackend

Inherits:
Object
  • Object
show all
Defined in:
lib/dockerspec/serverspec/specinfra_backend.rb

Overview

A class to handle the underlying Specinfra backend.

This class saves Specinfra instance in internally and then it is able to recover it from there and setup the running environment accordingly.

This class uses a small hack in the Specinfra class to reset its internal singleton instance.

Instance Method Summary collapse

Constructor Details

#initialize(backend) ⇒ SpecinfraBackend

The SpecinfraBackend constructor.

Parameters:

  • backend (Symbol, Specinfra::Backend::Base, Class)

    The backend can be the backend name as a symbol, a Specinfra backend object or a Specinfra backend class.



44
45
46
# File 'lib/dockerspec/serverspec/specinfra_backend.rb', line 44

def initialize(backend)
  @backend = backend
end

Instance Method Details

#resetObject

Resets the Specinfra backend.

Returns:

  • void



77
78
79
# File 'lib/dockerspec/serverspec/specinfra_backend.rb', line 77

def reset
  instance_set(nil)
end

#restoreObject

Restores the Specinfra backend instance.

Returns:

  • void



66
67
68
# File 'lib/dockerspec/serverspec/specinfra_backend.rb', line 66

def restore
  instance_set(@saved_backend_instance)
end

#saveObject

Saves the Specinfra backend instance reference internally.

Returns:

  • void



55
56
57
# File 'lib/dockerspec/serverspec/specinfra_backend.rb', line 55

def save
  @saved_backend_instance = backend_instance
end