When I execute rake spec against this rake file, docker compose turns up, then it shuts down before the unit tests are executed. If I remove the last command that runs docker-compose down it works fine
How do I modify the script so it can run docker-compose up --detach, then run the unit tests, then run docker-compose down after the unit tests are completed?
I tried adding a sleep and that didn't work as well.
In my Rakefile:
Spec::Core::RakeTask.new(:spec)
# start docker compose.
# we use the system command to wait until docker compose is up and running before starting unit tests
system("docker-compose up --detach")
# run unit tests
task :default => :spec
# stop docker compose
system("docker-compose down")
I think your problem not about
dockerbut aboutrake. Rake (like make) allows you to add dependencies to a task, and we can use the dependency links to arrange the order of tasks:here is the topic you can learn about how to use rake