dockerspec
dockerspec copied to clipboard
before :all not being executed
Dockerspec Version
0.4.1
Ruby Version
2.4
Platform Details
Mac
Scenario
Run the following, but :all
is not executed
describe 'thumbor' do
before :all do
image = Docker::Image.get(ENV['DOCKER_IMAGE'])
set :os, family: :alpine
set :backend, :docker
set :docker_image, image.id
puts `find docker-compose -type f -name "*.tpl.yml" | xargs -I% -n1 /bin/bash -c 'envsubst < % > $(dirname %)/$(basename % .tpl.yml).yml'`
end
#describe docker_run(tag: Docker::Image.get(ENV['DOCKER_IMAGE']).id, family: 'alpine', wait: 1) do
describe docker_compose('spec/docker-compose/default.yml', family: 'alpine', wait: 3) do
end
end
Steps to Reproduce
See code above.
Expected Result
Executing :all
before docker_run
, or others.
Actual Result
Not being executed.
I think this is strictly related to #8.
I guess the problem is not that it is not executed, but that it is executed after the docker_run
. The reason is that docker_run
should be run before running any test. It is executed at RSpec compile time in order to be able to check, for example, OS platform, outside it
blocks (see #2).
I mean, the problem is that RSpec execution has different stages and running the container in one or the other stage has its advantages and disadvantages. Keep in mind that RSpec before
blocks are run before the it
s blocks, but not before everything that is inside a describe
block.
IMHO, the best way to do what you are trying to do is to use docker_build
resource instead of a before
. If docker_build
needs to be extended to add a feature you need, I think that would be easier than trying to use before blocks to create your images. It may not be well explained in the README, but this gem is not meant to be used that way.