Class: Dockerspec::Serverspec::Runner
- Defined in:
- lib/dockerspec/serverspec/runner.rb
Overview
Runs a Docker container using Serverspec.
Class Method Summary collapse
-
.restore(metadata) ⇒ Object
Restores the Docker running container instance in the Specinfra internal reference.
Instance Method Summary collapse
-
#finalize ⇒ Object
Stops and deletes the Docker Container.
-
#initialize(*opts) ⇒ Dockerspec::Serverspec::Runner
constructor
Constructs a Docker Serverspec runner class to run Docker images.
-
#restore ⇒ Object
Restores the Specinfra backend instance to point to this object's container.
-
#run ⇒ Dockerspec::Serverspec::Runner
Runs the Docker Container and sets the Specinfra configuration.
-
#to_s ⇒ String
private
Generates a description of the object.
Methods inherited from Runner
Methods included from Helper::MultipleSourcesDescription
Constructor Details
#initialize(*opts) ⇒ Dockerspec::Serverspec::Runner
Constructs a Docker Serverspec runner class to run Docker images.
80 81 82 83 84 |
# File 'lib/dockerspec/serverspec/runner.rb', line 80 def initialize(*opts) super @specinfra_backend = nil @backend = calculate_docker_backend_name end |
Class Method Details
.restore(metadata) ⇒ Object
Restores the Docker running container instance in the Specinfra internal reference.
Gets the correct Dockerspec::Serverspec::Runner reference from the RSpec metadata.
143 144 145 146 147 |
# File 'lib/dockerspec/serverspec/runner.rb', line 143 def self.restore() runner = Helper::RSpecExampleHelpers.search_object(, self) return if runner.nil? runner.restore end |
Instance Method Details
#finalize ⇒ Object
Stops and deletes the Docker Container.
Actually does nothing. Do no delete anything, let Specinfra do that.
117 118 119 |
# File 'lib/dockerspec/serverspec/runner.rb', line 117 def finalize # Do not stop the container end |
#restore ⇒ Object
Restores the Specinfra backend instance to point to this object's container.
This is used to avoid Serverspec running against the last started container if you are testing multiple containers at the same time.
158 159 160 |
# File 'lib/dockerspec/serverspec/runner.rb', line 158 def restore @specinfra_backend.restore end |
#run ⇒ Dockerspec::Serverspec::Runner
Runs the Docker Container and sets the Specinfra configuration.
99 100 101 102 103 104 105 106 |
# File 'lib/dockerspec/serverspec/runner.rb', line 99 def run specinfra_setup run_container specinfra_save self rescue ::Docker::Error::DockerError => e DockerExceptionParser.new(e) end |
#to_s ⇒ String
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.
Generates a description of the object.
175 176 177 |
# File 'lib/dockerspec/serverspec/runner.rb', line 175 def to_s description('Serverspec on') end |