Let's talk about testing

Complete Setup Guide for Ruby, Cucumber and Watir on Windows

This entry is part 7 of 11 in the series Test Automation
This blog post is outdated. Please refer to our updated setup guide instead.


This is an updated version of our previous post on getting a cucumber installation set up on Windows. It has become one of the most popular resources for this on the web, but has aged a little since we published it in 2011.

With this updated guide, we’d like to kick off a new round of cucumber-related blog posts.

What is Cucumber?

Cucumber is an Open Source software tool for test automation. Its basic concept is that test cases should be captured in human language (a form of structured English called gherkin), but automating the execution of test cases is best done in a programming language. The cucumber tool provides the glue between the two, reporting test results in the human language again.

The next post in the series will provide an introduction to basic cucumber concepts.


We’ll start this round of cucumber posts with installation instructions so you can follow the next posts as you read them.

After following these instructions, you will have installed cucumber, as well as Watir, a convenient wrapper around the industry leading Selenium browser automation framework, as well as Ruby, the programming language of choice for cucumber test automation. With all three combined, we can test web applications as demonstrated in a later post.

Software Versions

These instructions have been tested on Windows 7 and Windows 8, with both 32bit and 64bit installations. Additionally, Ruby versions 2.0, 2.1 and 2.2 have been used for these instructions.

32bit vs. 64bit

All of the software packages we’re about to install run on 32bit Windows and 64bit Windows, with one small caveat: on 64bit Windows, cucumber will produce warnings about a missing “gherkin lexer”, but otherwise work just fine. If such warnings irritate you, you can work around them with some deeper knowledge of native Ruby gems. Otherwise, we recommend sticking to 32bit packages.

Step 1: Install Ruby

On Windows, the best place to start is the RubyInstaller download page. Download and install the Ruby version of your choice. We’ll use 32bit Ruby 2.2.2 here.

In main installer window, you have four choices to make:

  1. The installation path. We’re going to use C:\Ruby in this example rather than using a version-specific installation path. Whenever you see C:\Ruby, pick the installation path you chose here.
  2. Whether to install Tcl/Tk support. This is not required for cucumber.
  3. Whether to add Ruby executables to your path. This is required for the rest of these posts to work well.
  4. Whether to associate certain files with this Ruby installation. If you have only one version of Ruby installed, this is recommended.
Ruby Installer

Ruby Installer (64 bit)

Step 2: Extract DevKit

DevKit is required for some Ruby packages (called “gems”) to be installed. It can be downloaded from the same downloads page. Note that for Ruby 2.0, 2.1 and 2.2, the same version can be used. We’re using 32bit DevKit here.

The executable is just a self-extracting archive. You can extract the archive anywhere you want, but we’ll use C:\Ruby\devkit here.

DevKit Extraction

DevKit Extraction

Step 3: Install DevKit

Once DevKit is extracted, you need to go to the Windows Command Console to install it.

  1. Run a command by pressing the Windows key and the R key.
  2. Write “cmd” into the input field.
  3. Hit enter.
Run Command Console

Run Command Console

In the command console, go to the DevKit installation path, C:\Ruby\devkit, and enter two commands to finish the DevKit installation.

C:\Users\you> cd \Ruby\devkit
C:\Ruby\devkit> ruby dk.rb init
C:\Ruby\devkit> ruby dk.rb install

Step 4: Install Cucumber and other Ruby gems

Now you’ve got your system set up for Ruby to download and install “gem” packages. To install cucumber, first update the current gem setup:

C:\Users\you> gem update --system

Next, install the gems you need for cucumber web testing. We recommend at least the following:

C:\Users\you> gem install --no-ri --no-rdoc rspec
C:\Users\you> gem install --no-ri --no-rdoc win32console
C:\Users\you> gem install --no-ri --no-rdoc watir-webdriver
C:\Users\you> gem install --no-ri --no-rdoc cucumber

You can also install multiple packages in a single command, e.g.

C:\Users\you> gem install --no-ri --no-rdoc rspec cucumber

Step 5: Run Cucumber

At this point, you should be able to execute cucumber and watch it complain about not having tests to run.

C:\Users\you\Documents> cucumber
No such file or directory - features. You can use
    `cucumber --init` to get started.

Let’s do what cucumber suggests, shall we?

C:\Users\you\Documents> cucumber --init
  create   features
  create   features/step_definitions
  create   features/support
  create   features/support/env.rb

We’ll explain all the stuff that gets created here later. Right now, if we run cucumber again now, it’ll complain a lot less:

C:\Users\you\Documents> cucumber
0 scenarios
0 steps

And there you have it! Cucumber runs zero test scenarios containing zero steps, in zero seconds. That seems about right for a fresh installation!

Step 6: Install Bundler

Installing Ruby gems via the gem command is generally the way to install packages system-wide. If you work a lot on test automation suites, though, it’s quite likely that you want different versions of each package for different projects. For this purpose, the Ruby community has come up with bundler, which we thoroughly recommend to use in your test automation projects.

C:\> gem install bundler

We’ll discuss the use of bundler in later posts, but for now you should just install it so we can refer to it later.

Comments are closed.

Reputation. Meet spriteCloud

Find out today why startups, SMBs, enterprises, brands, digital agencies, e-commerce, and mobile clients turn to spriteCloud to help improve their customer experiences. And their reputation. With complete range of QA services, we provide a full service that includes test planning, functional testing, test automation, performance testing, consultancy, mobile testing, and security testing. We even have a test lab — open to all our clients to use — with a full range of devices and platforms.

Discover how our process can boost your reputation.

We use cookies to give you the best browsing experience possible. For more information, please read our cookie policy.

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.