Docker
Docker is becoming incredibly popular in the recent days. Docker containers are lightweight and can be launched as required. Well, this post is about provisioning Cucumber-Capybara BDD framework inside docker in order to execute Cucumber scenario inside the containers. This will install all the supporting tools as mentioned in the BDDfire.
Docker-BDD on DockerHub
In order to setup, Ruby-Cucumber framework inside docker, I have created a Docker image on DockerHub, called ‘docker-bdd‘
You can get click on image above to get to Docker-Hub and pull ‘docker-bdd‘.
Pulling Docker-BDD
Assuming you have Docker setup in your machine, you can launch docker vm. Please use docker docs in order to get you setup with docker.
Now, let’s pull the Docker image and let it provision
1 |
$ docker pull shashikant86/docker-bdd |
This will pull Ruby docker image and start provisioning PhantomJS, RubyGems and BDDfire. You can find detailed build output on dockerhub. Build logs can be found here
Provisioning RubyGems
Launch docker container
Assuming pull is success, we can now check that docker image is present. It should look something like this :
1 2 3 4 |
$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE docker-bdd latest 7804328e50e5 About an hour ago 1.559 GB ruby 1.9.3 303f2fe874a2 4 months ago 731.2 MB |
Now, We can launch container with following command:
1 |
docker run -t -i docker-bdd /bin/bash |
Now that you should be inside the docker container and in the ‘/opt/bdd/cucumber’ directory with all the gems installed.
Now run BDDfire rake tasks inside containers using bundler.
1 |
$ bundle exec rake poltergeist |
You will see the cucumber scenario is passing with headless PhantomJS based driver Poltergeist.
You can add more scenarios and run them inside docker container.
Feel free to give it a try. Source code is on Github
https://github.com/Shashikant86/docker-bdd
Let me know if you got stuck !
Happy BDD !!
Watch Video Demo