dockerspec icon indicating copy to clipboard operation
dockerspec copied to clipboard

docker_compose doesn't shutdown container after describe end

Open estahn opened this issue 7 years ago • 5 comments

Dockerspec Version

0.4.1

Ruby Version

2.4

Platform Details

Mac

Scenario

Run docker_compose from the same file in 2 different specs.

test1_spec -> docker_compose(default.yml)
test2_spec -> docker_compose(default.yml)

Steps to Reproduce

Expected Result

After describe docker_compose() do ... end the containers should shutdown.

Actual Result

Containers stay active until rspec is finished.

Possible Solution

In order to maintain backwards compatibility it might be worth to introduce a new flag shutdown for the docker_compose method.

estahn avatar Apr 04 '17 06:04 estahn

@estahn unfortunately, I do not think this can be fixed due to the way rspec and serverspec work.

Right now all the containers are started, then the tests are passed, and then they all stop in a third stage. I tried to change this some time ago, but it seemed impossible.

In addition to that, and even if it were possible, this would imply that you could not execute things like os[:family] out of it / before blocks. And sometimes that's the case, as commented in #2.

zuazo avatar Apr 04 '17 07:04 zuazo

It appears rspec doesn't have an isolation feature similar to phpunit. I'm running it now manually in "isolation" :)

find spec -name "*_spec.rb" | xargs -I% -n1 /bin/bash -c 'MY_VAR=123 bundle exec rspec %'

estahn avatar Apr 04 '17 08:04 estahn

Yes, that's a good solution.

Maybe it could be possible to implement some kind of special resource, something like a docker_context do ... end to isolate the different executions of rspec&docker. I wrote it down in the TODO list. I researched how to do it some time ago, but I could not figure out how. I'm not saying it's impossible, but it does not seem like a simple task.

zuazo avatar Apr 04 '17 09:04 zuazo

I tried experimenting with describe ... context but this didn't seem to work. It would be great to avoid introducing a new thing.

estahn avatar Apr 04 '17 09:04 estahn

With the original describe is not possible to do that. However, it does not seem possible to do it the other way either without changing the internal behavior of RSpec.

zuazo avatar Apr 04 '17 09:04 zuazo