Installing Ruby

Before you can install Cucumber, you need to install Ruby. The code in this book was tested with Ruby 2.3.1, and we recommend you use this version or a more recent one. Each operating system has different ways to install Ruby. This appendix walks you through the most common installation procedures for OS X, Linux, and Windows.

OS X and Linux

First, you are going to need a C compiler such as GCC or Clang installed to build Ruby and gems that use C extensions, including Cucumber. On OS X you will have to install Xcode. Each Mac ships with a DVD that contains Xcode, and it can also be downloaded from http://developer.apple.com/xcode/.

Some Linux distributions come with GCC and/or Clang pre-installed, but many (such as Ubuntu) do not. Just to be on the safe side, Linux users should install some packages. The following commands should work on Ubuntu and other Debian distributions:

 $ ​​sudo​​ ​​apt-get​​ ​​install​​ ​​build-essential​​ ​​curl​​ ​​zlib1g-dev​​ ​​libreadline-gplv2-dev
 $ ​​sudo​​ ​​apt-get​​ ​​install​​ ​​libssl-dev​​ ​​libxml2-dev​​ ​​libxslt-dev​​ ​​sqlite3​​ ​​libsqlite3-dev

That will install GCC and some other tools you’ll need to build Ruby and the various gems used in the book. You should now be ready to install RVM.

We recommend you use RVM (Ruby Version Manager) to install Ruby. RVM is a command-line tool that allows you to easily install, manage, and work with multiple Ruby environments from interpreters to sets of gems. That means that even if you already have another version of Ruby installed, you can use the same one as these code examples have been tested with.

To install and use RVM, you’ll first need to install Git, which you can download from http://git-scm.com/download. On Ubuntu you can install Git with sudo apt-get install git-core.

Follow the installation instructions on the RVM website (https://rvm.io/rvm/install). Make sure to follow the post-installation instructions—including restarting your terminal—to set up a simple rvm command you can run from a shell. When you have installed RVM, use it to install Ruby 2.3.1 and make that your default Ruby interpreter:

 $ ​​rvm​​ ​​install​​ ​​ruby-2.3.1
 $ ​​rvm​​ ​​--default​​ ​​ruby-2.3.1

Windows

We recommend you use Ruby Installer to install Ruby on Windows. You can get it from http://rubyinstaller.org/.

You’ll then need to install the Ruby Installer Development Kit after you have installed Ruby. This installs a GCC compiler tool chain that will allow you to install gems that use C extensions later. (You cannot use Visual Studio for this). You can get the Ruby Installer Development Kit from http://rubyinstaller.org/add-ons/devkit/.

If you have any problems during installation, please refer to the troubleshooting page for Ruby Installer: https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting.

Console Colors on Windows

Cucumber uses ANSI escape codes to print colored output to the console. This isn’t supported natively in Windows, so you have to install a tool called ANSICON to see colors.

Download and unzip the latest version from https://github.com/adoxa/ansicon/downloads. Open a command prompt and cd to the folder where you unzipped it. Now, cd into either x86 or x64 (depending on your machine’s processor) and install it globally on your machine:

 C:somewhereansi140x64>​​ ​​ansicon​​ ​​-i

Any program that prints ANSI colors will now display properly on your machine.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.71.106