Skip to content

Instantly share code, notes, and snippets.

@maxdanilov
Last active May 8, 2017 01:49
Show Gist options
  • Save maxdanilov/17be29ef3b31fdcf70bec0b864632ef3 to your computer and use it in GitHub Desktop.
Save maxdanilov/17be29ef3b31fdcf70bec0b864632ef3 to your computer and use it in GitHub Desktop.
[Serverspec] running tests inside a Docker container
require 'spec_helper'
# the root folder should contain Dockerfile so build_from_dir can work
describe "mycontainer" do
before(:all) do
image = Docker::Image.build_from_dir('.')
@container = image.run()
set :os, family: :debian
set :backend, :docker
set :docker_container, @container.id
end
describe command('sleep 1') do
its(:exit_status) { should eq 0 }
end
after(:all) do
@container.kill
@container.delete(:force => true)
end
end
@maxdanilov
Copy link
Author

Gemfile for this:

source "https://rubygems.org"

gem 'docker-api'
gem 'serverspec'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment