Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before :all not being executed #7

Open
estahn opened this issue Apr 3, 2017 · 1 comment
Open

before :all not being executed #7

estahn opened this issue Apr 3, 2017 · 1 comment

Comments

@estahn
Copy link

estahn commented Apr 3, 2017

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.

@zuazo
Copy link
Owner

zuazo commented Apr 4, 2017

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 its 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.

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

No branches or pull requests

2 participants