`ensure_application_exists!’: Xvfb not found on your system (Headless::Exception)

group :test,:development do
gem 'capybara'
gem 'capybara-webkit'
end

Firstly you need to use the capybara-webkit and install QT dependencies in your OS.

Ubuntu

sudo apt-get install libqt4-dev libqtwebkit-dev

Ubuntu 10.04 LTS

sudo apt-get install libqt4-dev

Debian Stable

sudo apt-get install libqt4-dev

Fedora

yum install qt-webkit-devel

Fedora 16

yum install qtwebkit-devel

If you are using a recent version of Fedora, the qmake executable is now called qmake-qt4. This will cause the gem installation to fail. So you need to add an environment variable your profile or the system profile.

export QMAKE=/usr/bin/qmake-qt4

Gentoo Linux

You will need to install xvfb and also use Headless gem. Headless is the Ruby interface for Xvfb. It allows you to create a headless display straight from Ruby code, hiding some low-level action. It can also capture images and video from the virtual framebuffer.