FROM ubuntu:14.04 | |
MAINTAINER Mason Fischer <mason@thoughtbot.com> | |
RUN apt-get update && apt-get install -y nodejs |
require "serverspec" | |
require "docker" | |
describe "Dockerfile" do | |
image = Docker::Image.build_from_dir('.') | |
set :os, family: :debian | |
set :backend, :docker | |
set :docker_image, image.id | |
it "installs the right version of Ubuntu" do | |
expect(os_version).to include("Ubuntu 14") | |
end | |
it "installs required packages" do | |
expect(package("nodejs")).to be_installed | |
end | |
def os_version | |
command("lsb_release -a").stdout | |
end | |
end |
This comment has been minimized.
This comment has been minimized.
yo Vamsi you want to take a look over at my comment here. Basically, you've got a newer version of specinfra which has a 'fix' for Containers with nil I'd recommend just watching that issue and see what happens, in the meantime, downgrade your serverspec and specinfra. |
This comment has been minimized.
This comment has been minimized.
Hi @dekz, Thanks for your reply.Can you recommend me the version to use for serverspec and specinfra.it will be great help so that i can see if this sort issue occurs again in my env Thanks, |
This comment has been minimized.
This comment has been minimized.
Hm. I'm getting this error:
Which is weird because it really is installed. |
This comment has been minimized.
This comment has been minimized.
arioch to be honest I haven't had a look at how the internal of serverspecs works with regards to checking packages installed. But since yours is up and running unlike Vamsi's then I'd suggest digging in a bit further. Vamsi, try |
This comment has been minimized.
This comment has been minimized.
I didn't have any success getting this to work using latest serverspec and specinfra |
This comment has been minimized.
This comment has been minimized.
I wonder if the problem is their in my setup or with the above spec file Here is what some thing i get after the specinfra v2.15.0 installed
Here are some of my machine details
Btw the commit is more specific to the CMD inside the Dockerfile to check or with the cmd to execute in the spec file? |
This comment has been minimized.
This comment has been minimized.
@masonforest great blog post! Any suggestions on how to go about removing the images after the tests get run? I've tried it this way, but this doesn't seem right (or to work!) |
This comment has been minimized.
This comment has been minimized.
Just calling out: it's important to specify that you should use the |
This comment has been minimized.
This comment has been minimized.
@cjcjameson you just saved me a lot of time buddy, thx. and thx @masonforest ! |
This comment has been minimized.
This comment has been minimized.
Oh my! The docker-api gem! what a difference that makes! @masonforest - do you think you can update the article to call this out? it would have saved me a bunch of time! |
This comment has been minimized.
This comment has been minimized.
@tfhartmann : I add this to my specs: after(:all) do
@image.remove(:force => true)
end |
This comment has been minimized.
This comment has been minimized.
In the example you build the image only. I assume ServerSpec is starting the container and stopping by the end of the test. How can you pass arguments to the container such as environment variables, commands, volumes, etc? |
This comment has been minimized.
This comment has been minimized.
Hello, this is my version of docker:
I can't using rspec and always getting this message:
this is my directory structure:
|
This comment has been minimized.
Hello,
I get this error
Dockerfile
installs the right version of Ubuntu (FAILED - 1)
Failures:
Failure/Error: command("lsb_release -a").stdout
NoMethodError:
undefined method `stdout' for #Docker::Container:0x0000000212b3d8
Finished in 0.36045 seconds (files took 0.8135 seconds to load)
1 example, 1 failure
And i would like to know the serverspec and ruby version you are using ?
Thanks,
Vamsi KGR