Learn how to integrate your automated tests with Capybara and Codeship.

Bruno Batista
automation with batista
5 min readNov 9, 2018

--

But first let’s talk about continuous integration?

Continuous integration is a DevOps software development practice where developers often combine their code changes into a central repository. After that, creations and tests are executed. Generally, continuous integration refers to the stage of creation or integration of the software launch process, as well as an automation component (example: an IO or creative service) and a cultural component (example: frequency).

And what is the main objective of continuous integration?

The main goals of continuous integration are to find and investigate bugs faster, improve software quality, and reduce the time it takes to validate and launch new software updates.

What is Codeship?

Codeship is a hosted continuous delivery service that focuses on speed, reliability and simplicity. You configure Codeship to create and deploy your GitHub application to the scenario or production platform of your choice.

The service offers a variety of powerful configuration options. Currently, the Codeship is integrated with the popular source code managers GitHub and Bitbucket. It supports a variety of programming languages ​​(Ruby on Rails, Node.js, PHP, Java, Go, Dart, etc.) and deployment platforms (Amazon Web Services, Heroku, Google App Engine, etc.)

The practice of continuous integration involves repeated automated testing and merging code with notifications to alert developers to problems in their code in real time. The Codeship combines this with continuous delivery practice, which provides for the regular deployment of codes once the changes have passed automated testing.

How to configure the project to run in Codeship?

To run our automated tests together with the Codeship we will have to configure the chrome headless in our design made in capybara and ruby

What is headless chrome and how to install?

This Thoughtbot post speaks highly of how to install and run tests with Chrome Headless.

Once you have made the steps from the above post now let’s integrate the project together with the Codeship?

So let's set up our Codeship?

Once you have made the steps from the above post now let's integrate the project together with the Codeship?

1- Passo

Create an account on Codeship is free:

https://app.codeship.com/registrations/new?utm_source=NavBar

2- Step

Choose which repository you use, in my case I use Github, so I'll use it in the examples, but the concept is the same for the other repositories.

3- Step

In this screen you will put the link of your project, same thing as if you were to clone your project. Just copy the same link from the image below and paste it into the Codeship page.

4- Step

In this class we will use the basic version.

5- Step

Let's choose which language we use in Codeship, in this post we use the Ruby language.

After choosing the language the Codeship will already create some basic commands.

The Codeship already comes with several packages already installed in it by default, if you need to know which ones are just access this link below:

https://documentation.codeship.com/basic/builds-and-configuration/packages/

The configuration commands we will use to run the automated tests are:

#we are installing version 2.4.2 of RVM

rvm use 2.4.2 — install

#Giving an update on the chromedriver and setting the version to be used.

The Codeship already comes standard installed the chromedriver.
The Codeship has already installed the chrome.

chromedriver-update

export CHROMEDRIVER_VERSION=2.33

#Setting the ruby ​​version

rvm use $(cat .ruby-version) –install

6- Step

Once you have configured the environment now we will configure the commands to run the tests.

#I'm entering inside the folder where my Gemfile file is:

cd src

#Installing the dependencies I've selected in my Gemfile:

bundle install

#Running the command to run my project:

bundle exec cucumber

Then just save that Codeship will automatically run your tests.
Clicking on the project you will see a dashboard like this one below.

At the end of the tests you will have 3 types of situations:

Success — This is the best case where all the tests have passed.

Error — When something from the Codeship gave error or failed.

Failed — When your tests failed.

With this we finish the post of continuous integration with Codeship and Capybara.

Anything can contact me :).

References:

--

--