Building capybara-webkit 0.x

Capybara is not only an animal but also a very powerful system testing library for Ruby. It uses a browser (also headless) to click through your webpages and make assertions. A well known browser driver for Capybara is capybara-webkit, a gem maintained by Thoughtbot.

The capybara, a cute fluffy animal

Building the Ruby gem

If you’ve tried to install capybara-webkit, you maybe encounter problems because your QT version is newer than 5.5 (they’ve dropped Webkit support). You can get help here to install capybara-webkit with QT5 support.

The real problem starts if you need to build a really old version. I had to build capybara-webkit 0.13.2 on Mac OSX Sierra. Luckily someone already made the effort to provide QT4 for Homebrew, so all I had to do to install the gem was the following:

brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt@4
brew link --overwrite qt@4
brew install qt-webkit@2.3
export PATH="/usr/local/opt/qt@4/bin:$PATH"
gem install capybara-webkit -v '0.13.2'


QT4 is very old and insecure. Be sure to be in full control of the webpages the driver renders. The project I needed it for is about to be migrated away from capybara-webkit. You probably should do that as well if you’re reading this, or at least update.