Disclaimer: I am very new to ruby โโand rspec
I am trying to create a private repo with docker images as base images for our various projects. We are also trying to enable testing of several docker images as part of a test suite.
We have a strange problem with rspec, it seems that the tests are running on the wrong docker machine.
We currently have two docker images in a separate folder
.
โโโ Dockerfile
โโโ Gemfile
โโโ Gemfile.lock
โโโ Jenkinsfile
โโโ README.md
โโโ Rakefile
โโโ nodejs
โ โโโ 7.0
โ โ โโโ Dockerfile
โ โ โโโ README.md
โ โ โโโ spec
โ โ โโโ image_spec.rb
โ โโโ README.md
โโโ python
โ โโโ 2.7
โ โ โโโ Dockerfile
โ โ โโโ README.md
โ โ โโโ docker-entrypoint.sh
โ โ โโโ requirements.txt
โ โ โโโ spec
โ โ โโโ image_spec.rb
โ โโโ README.md
โโโ spec
โโโ spec_helper.rb
This is basically the structure we are currently using, ours spec/spec_helper.rbusing default / simple
require 'serverspec'
require 'docker'
RSpec.configure do |config|
config.color = true
config.tty = true
config.formatter = :documentation
end
And this is the Rakefilecontent we use
require 'rake'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec) do |t|
t.pattern = Dir.glob('*/*/spec/*_spec.rb')
t.rspec_opts = '--format documentation --require spec_helper --color'
end
task :default => :spec
, , , bundle exec rake rspec python/2.7/spec_image.rb , , nodejs/7.0. bundle exec rspec python/2.7/spec/image_spec.rb, .
image_spec.rb python/2.7
require 'serverspec'
require 'docker'
DOCKER_FOLDER = "python/2.7"
describe "Python/2.7 Specs" do
before :all do
add_simplejson_to_requirements
image = Docker::Image.build_from_dir(DOCKER_FOLDER, ARG: 'requirements.txt')
set :path, '/usr/local/bin:$PATH'
set :os, family: :alpine
set :backend, :docker
set :docker_image, image.id
end
it 'has python 2.7 installed' do
expect(command('python -c "import sys; print(sys.version_info[:])"').stdout).to include\
'2, 7'
end
it 'installs requirements.txt given as --build-arg' do
expect(command('pip install simplejson==3.6.3').stdout).to include\
'Requirement already satisfied'
end
end
- ?