The main advantages of this way are to have an independent environment for the tests running and to reduce the complexity of the test environment setup.
What we want to achieve:
* Running the tests should be easy.
* Test runs should be isolated and repeatable.
* Test environment should be as close to the production environment as possible.
How to setup and use docker-compose for Ruby on Rails tests you can find in the article: [https://jtway.co/running-tests-in-containers-with-docker-compose-97480726c1e3](https://jtway.co/running-tests-in-containers-with-docker-compose-97480726c1e3)