Installing ruby with cucumber on a linux machine (Ubuntu)

From Test Automation Wiki
Jump to: navigation, search

Installing Ruby 2.3.1

Note:This tutorial is based on an UBUNTU 14.04 LTS version.

  1. Install RVM on
  2. Upgrade RVM
    • rvm get stable
  3. Install latest ruby
    • rvm install ruby-2.3.1

Installing the necessary plugins

Now the installation of Ruby is complete, we can start installing the necessary plugins. These are so called “Gems” in Ruby. (A ruby is a gem, so the creators decided to call their plugins gems)

Copy the code written below and paste it in the Terminal (right click, paste)

gem update --system
gem install ffi
gem install rspec
gem install selenium-webdriver
gem install watir-webdriver
gem install lapis_lazuli
gem install cucumber

Useful Terminal commands :

  • gem help commands    --> displays a list of all gem’s commands
  • gem list    --> displays list of all locally installed gems
  • ruby -v    --> displays installed ruby version
  • rvm info    --> displays the paths where ruby and rvm are installed among other info

Projects Folder

  1. Create a folder named ‘ruby’ in home with the linux GUI:
    • home/user/ruby
      1. ~/ruby/
  2. Projects folder path should look like:
    • sCuser@Asus-X202EP:~/ruby/projects/projectName$

Cucumber - Firefox marionette Geckodriver

To run cucumber you will need to do the following (when using a selenium version below 3v):

  1. Download the firefox marionette webdriver
  2. Download the geckodriver
  3. Extract and unzip and move the geckodriver file to /usr/local/bin/ directory
    • /usr/local/bin/ → /home/sCuser/bin/
  4. Run ruby program with selenium Firefox webdriver.

With Selenium 3.0 and later, you shouldn't need to do anything to use Marionette, as it's enabled by default.

More information about the installations above
gem update --system Will update all default gems installed with Ruby (can be outdated, even though you've just installed Ruby)
gem install rspec Commonly used gem
gem install selenium-webdriver Gem that allows communication with liowsers
gem install watir-webdriver Layer on top of Selenium that simplifies liowser interaction
gem install lapis_lazuli Test automation gem that will enforce best practices, forcing the TA engineer to produce better code.
gem install cucumber The software that will run the scripts from console.

That's it! You're now ready to start setting up your cucumber project. You can read more about this in the next article.