Cannot install Ruby Gem – certificate error

I just encountered a problem trying to install first the rails gem and then the watir gem.

I executed:

$ gem install rails

it failed with an OpenSSL error, a bit later I tried to install watir using:

$ gem install watir

I was surprised to see that it also failed with

# Unable to download data from - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (

I wondered it might have something to with the fact that I am using rvm to manage my ruby environments, it turns out that it does indeed. It seems that the certificates in rvm must be updated manually every so often.

If you check the status of the certificates in rvm by running:

$ rvm osx-ssl-certs status all

you will probably see

# Certificates for /etc/openssl/cert.pem: Old.

to update them, run:

$ rvm osx-ssl-certs update all

(Note – you may need to enter your password.)

Hey presto, your problem should be resolved!


Testing iOS apps with calabash – PART 2

In the last chapter we installed lots of goodies to make our mac a more productive environment and one more conducive to using on.

In this chapter we will configure our bash_profile so that rvm is available every time we use the terminal window, then we will install and finally at the end of the chapter we will runs test using


RVM is a version manager for Ruby. It allows us to switch between versions of Ruby. You may have several projects going as once and each project may be built on a different version of Ruby. Instead of hacking your system around and making a pigs ear of things, rvm does all the heavy lifting, allowing us to install and switch ruby versions in one simple command line statement.

Now – if you’ve followed my instructions in Chapter 1, you will have ruby v2 installed.

Now if we want to instal other versions of ruby we can use dvm to manage them, but when I tried running

$ rvm install 1.9.2

to install version 1.9.2, I ran into a problem – basically the installer hung at the gcc part – so I had to do the following:

$ brew update

$ brew tap homebrew/dupes

$ brew install autoconf automake apple-gcc42

$ rvm pkg install openssl

$ rvm reinstall all —force

$ sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

$ rvm install 1.9.2

So now ruby 1.9.2 is installed let’s just take a look at the list of rubies that we have on our system and which one we are using, we do this by typing:

$ rvm list

my response is:

rvm rubies
ruby-1.9.2-p320 [ x86_64 ]
=* ruby-2.0.0-p247 [ x86_64 ]
=> – current
=* – current && default
* – default

This shows us that we have ruby 1.9.2 and ruby 2.0.0 installed and that we are using ruby 2.0.0 as our current and default ruby installation.

Please note, each time you use rvm it is a good idea to make sure you have the latest version. You can do this by entering:

$ rvm get stable —autolibs=enable.

Now using rvm, if you want to set 1.9.2 as the default version you can ruby version you can just issue the command:

$ rvm use 1.9.2

RVM is a useful tool. I suggest you take a look at to find more info on how to change your default, check paths to you versions etc.

Our App We’re going to need something to test against. If you don’t already have the source code for an app, has a sample app that we can use. To get the source code we need to get it from Github. To do this we do what is called “clone” the git repository. The git repository is: and to ‘clone’ the github repository (repo) we do the following: cd into the folder where you will keep your apps source code, then issue the command to clone the repo:

$ git clone

this will make a calabash-ios-example folder containing the source code for the App.

Do the set up

In terminal, cd to your app folder, in my case, this is:

$ cd ~/App/calabash-ios-example/

then install the calabash-cucumber gem:

$ sudo gem install calabash-cucumber

then run the calabash project set up:

$ calabash-ios setup

Then follow the instructions in your terminal console. This is done by running the -cal target from Xocde.

First we’ll do this, then I’ll explain what we’ve just done.

In Xcode, open the .xcodeprojfile for your app – this is in the folder LPSimpleExample if using the sample app.

Then, go to the scheme toolbar – in my workspace it’s under Product > Scheme. Select the app which is post fixed with -cal, in my case LPSimpleExample-cal

Build the app.

The simulator will start and in the in the application log (which is in the bottom right of your Xcode workspace) you will find a message which say “Started LPHTTP server on port xxxxxx” – this verifies that your project has been built and is running under calabash.

What we have done here is instruct the app to use the calabash framework (hence the postfix -cal)

Finally, we can generate the skeleton folders for our tests:

$ calabash-ios gen

then run our first test:

$ cucumber

We should see 1 passed scenario and 4 passed steps.

That’s us set up and ready to rock and roll.

Next chapter – diving deeper – writing our own tests

Calabash for testing iOS apps Part 1

Installing calabash on a vanilla mac is not a 2 minutes process. There are number of packages that you will need on your machine in order to make the set up and use of possible.

Those items are:

  • Xcode
  • Xcode command line tools
  • Ruby min version 1.8.7
  • Homebrew
  • Github
  • RVM (if you don’t want to mess around with your main Ruby install – this is not a MUST but I highly advice you to install it)

This guide will take you through that process.


  1. Get Xcode (if you haven’t got it – get it at the App Store)

Command Line Tools

Note – you may need an Apple developer log-in to get the command line tools

  1. Get the Command Line Tools for Xcode – the easy way to get these is to open Xcode > Got to Xcode on the menu bar, then click Open Developer Tools, then click More Developer Tools… – this will take you to a page will have the latest version of Command Line tools at the top – just download the dog and install.

Check that the command line tools have installed properly by running:

$ gcc —version

You should get a response similar to this:

Configured with: —prefix=/Applications/ —with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

If you get:

clang: error: no input file , don’t panic, you’ve probably typed gcc -version (1 hyphen) instead of gcc —version (2 hyphens)


  1. Now this is an optional step, but if you don’t have home-brew installed on your mac then I suggest that you do. It is a package manager which makes installing a whole host of tools as easy as stating typing ‘brew’ at the command line.
  2. As a pre-requisite to doing this, just double check that you have ruby installed and check that the version is at least 1.8.7. To do this enter:
ruby -v

You should see a response saying something like:

ruby 1.8.7 [patch info] [other info].

OK – now to install home-brew – enter at the command line. Please note – you may have to prefix this with sudo or run as admin/root.:

ruby -e “$(curl -fsSL”

When the installation has complete, execute the command brew doctor at the cmd line to check that the install is ok. If there are any problems, go through and fix them one by one…running brew doctor until there are no more issues. – Issues that I encountered were numerous to be honest – such wrong version of Xcode; macports being installed and various other things.


  1. So we have brew installed – time to install Git. Git is a version control system. The calabash code is held in github.

First thing we do is run at the command line:

brew update

It is good idea to get into the habit of running brew update before installing anything – it makes sure we always have the most recent copy.

So to install git – we can use the magic of home-brew by entering the following at the command line:

brew install git

When it’s finished we get something like this before our prompt:

🍺 /usr/local/Cellar/git/1.8.4: 1339 files, 30M

Next thing we do is run ‘brew doctor’ to make sure everything is still ok.

In my case I already had an install of git and had to overwrite it.

Now very your installation of git by entering

$ which git

you should get

$ /usr/local/bin/git

Let’s now configure git with you name and email address. so on the command line enter

$ git config —global “Gin AN Tonic”

$ git config —global “”

Install RVM (with the latest Ruby on Rails)

  1. Now this is the last part before calabash itself. We are going to install RVM and while we are at it Ruby on Rails. Go to the command line and enter:
$ \curl -L | bash -s stable —rails —autolibs=enable

When it has finished installing, check it with the following command:

$ type rvm | head -1

response should be

rvm is a function

Now check the versions of both rvm, ruby & rails…enter

$ rvm -v

response should be dvm 1.19.1 or higher

$ruby -v

response should be ruby 2.0.0p0 or higher.

$ rails -v

response should be Rails 3.2.13 or higher

Lastly check that everything is ok with homebrew by running brew doctor again. You might seem some messages saying that the kegs in the cellar are unlinked. Brew gives very explicit instructions – follow them and you will easily be able to link, relink or overwrite any kegs which are causing problems in your cellar.

That’s it for the moment.

In PART 2 – using RVM to manage your versions of Ruby, installing calabash and running our first test.