- Overview
- Transcript
4.3 Test a Ruby Project
In this lesson, I'll show you how to test a Ruby project. We'll also take a look at the Jenkins test output and try to make it prettier and more informational.
1.Introduction4 lessons, 12:21
1.1Introduction01:07
1.2What Is Continuous Integration?04:54
1.3Development Approaches: Git Flow and GitHub Flow04:38
1.4Project Overview01:42
2.Git Flow, Travis CI and Engine Yard4 lessons, 33:15
2.1Travis CI Overview09:01
2.2Test a New Feature07:43
2.3Release and Hotfix08:04
2.4Engine Yard Deployment08:27
3.GitHub Flow, Codeship and Heroku3 lessons, 24:51
3.1Codeship Overview09:24
3.2Develop a New Feature09:49
3.3Heroku Deployment05:38
4.Bonus: Custom Jenkins Server and Capistrano4 lessons, 26:45
4.1Installing Jenkins on a VPS02:31
4.2Jenkins Overview10:08
4.3Test a Ruby Project06:02
4.4Capistrano Deployment08:04
5.Conclusion1 lesson, 01:02
5.1Conclusion01:02
4.3 Test a Ruby Project
Hi. Welcome back to Continuous Integration of Workflow. In this lesson, we will test our raise up using Jenkins and also add some metrics to it. In Jenkins we have to adapt a few things. First, we need to install a few additional plug ins. The first one is ruby metrics, the second one, is x unit. After installation is complete, we can change our project's configuration. First of all it would be great to have the same functionality like Travis CI and Code ship. A change to start and build and a changed is pushed to get up. Let's enable the check mark for that. We also need to change the settings of the get up repository. On the web hooks and services, we can add a new service called Jenkins, and we are using the GitHub plugin. The hook url is going to be our ip address import, and we have to add GitHub web hook to it. Whenever we push to GitHub from now on, the build will trigger and Jenkins. Next up is a new Rake test. We have to set up the database before the tests, therefore we need to run db create and db schema load. To create the correct database we need to export the correct RAILS environment in this shared script. The spec task will also need changing since we want to create test reports. We will use the RspecJunitFormatter and save it to rspec.xml. Now, we have to add post build actions. The first one is Publish Rcov report. And the other one is publish XUnit test result report. In the first one we need to set the report directory to coverage/rcov. For XUnit we have to specify JUnit and provide the pattern, which is rspec.xml. Before we can run a new build, we have to make some changes on the Jenkins server itself. We need the Jenkins database user to be able to connect and create databases. As root, first run su- postgres to switch to deposit previous user. And then run createuser -s to create a superuser Jenkins. In our project we need to add some gems to development and test group. The first one is simplecov. Then simplecov-rcov and finally rspec_junit_formatter. We also have to add some code to the beginning of the array's output file, which is requiring simplecov and simplecov_rcov then setting the formatters to arc-formatter and the HTML formatter. The second one is for development. So you also get a [INAUDIBLE] color report locally. Then we start SimpleCov with the latest configuration. Now, we only have to run bundle install, and then commit the changes to Git. The build triggered successfully while GitHub with a matter of few errors that are very specific to my server. As you can see, it took me a few builds to get it fixed. First of all, my rake invocations didn't like the gem set anymore, which caused it to revert to default. I'm sure you noticed that earlier. So now I had to use a new gem set. And when using a rake task you can't simply pass options to. You have to use an inline environment variable called spec opts. Finally, I had a typo in a coverage directory. When we look at the output, you can see a trigger two successful builds to show you the graphs you will receive. The first is the code coverage. The second one is the test result trend. Since all tests passed there are no failed tests visible. You can also look at it in detail. The Rcov report shows test coverage for each and every file. The test results can also be viewed in detail down to each individual test. As you can see, there is a lot of information you can receive with those plugins. And there are many more. The more builds you have, the better the graphs look. In the next lesson, we will deploy the application to a VPS using Capistrano. See you there.







