Skip to content

Latest commit

 

History

History

docker-tdd

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

TDD and Docker with Serverspec

TDD is a software-development concept. Here we are demonstrating how some aspects of TDD can be adapted for use in Dockerfile development.

  • This example demonstrates using some aspects of Test-Driven Development to develop an example Dockerfile.
  • Each subdirectory here will give you a step-by-step understanding of how our Dockerized application evolves.

About our Application

How To Use

Prerequisites

  1. A Linux system with the ability to run Ruby, Gems and Bundler is required.
  2. Docker 17.05-ce or greater should be installed.
  3. A basic knowledge of Ruby, Rubygems, Gemfiles and Bundler is advised.
  4. Understanding of the Docker API for Ruby is advised.

Step 1. Create the directory structure.

  • First we create the stub files and folders necessary.
  • See step-1 directory for details.

Step 2. Create Failing Tests.

  • Next, we flesh out the specs (or "behavior" if you will) of our Docker image.
  • See step-2 directory for detail.

Step 3. Create the Dockerfile and Make Tests Pass.

  • Next we flesh out our Dockerfile so as to fulfil the specs.
  • After incrementally filling out our Dockerfile we execute the spec each time.
  • See step-3 directory.

Step 4. Loop: Implement Dockerfile, Make Tests Pass, Refactor!

  • Continue implementing the rest of the tests.
  • Watch the tests fail, implement your Dockerfile and rerun the tests until they pass.
  • Refactor as necessary.
  • See step-4 directory.

References

  1. Serverspec
  2. This gist
  3. Rspec: creating pending examples
  4. Guidelines for writing RSpec Tests
  5. The ServerSpec documentation
  6. Docker API for Ruby
  7. Existing articles on TDD and Docker: 1, 2, 3