Monday, December 31, 2012

Configuring Cucumber for Testing

Before using Cucumber, you'll need to install Ruby.  Here's how I do it:

For OSX, it can be as easy as:

$ brew update
$ brew install rbenv
$ brew install ruby-build
$ rbenv install 1.9.3-p194
$ rbenv rehash
$ rbenv global 1.9.3-p194
$ gem install bundle
$ gem install bundler
$ gem install rake

When using Bundler to manage project gem dependencies, I prefer to use RBENV rather than RVM.

Minimal Gemfile for Cucumber testing 

source ''
gem 'rake'
gem 'cucumber'

If you're on a Windows platform, which I'm not, you'll want to include the following:
 gem 'win32-process', :platforms => [:mswin, :mingw]
 gem 'win32console', :platforms => [:mswin, :mingw]

p.s.  If you're doing Ruby development, you may want to do yourself a favor and buy a Mac, or install linux.  Frequently, Windows and Ruby development do not mix well.

You can use groups in the Gemfile as follows:
group :cucumber do
  gem 'capybara'
  gem 'database_cleaner'
  gem 'cucumber-rails'
  gem 'cucumber', '0.7.3'
  gem 'rspec-rails', '>= 2.0.0.beta.10'
  gem 'spork'
  gem 'launchy'    # So you can do Then show me the page

Other popular gems used in testing include:
gem 'sqlite3'
gem 'require_all'
gem 'rspec'
gem 'page-object'
gem 'data_magic'
gem 'fig_newton'
gem 'gmail'
gem 'activerecord'
gem 'database_cleaner'
gem 'factory_girl'
gem 'mongoid'
gem 'bson_ext'
gem 'nokogiri'
gem 'debugger'

bundle install –binstubs

In order to alleviate some of the noise of bundle exec, Bundler 1.0 ships with a --binstubs flag, which will create a bin directory containing each of the executables that the application’s gems expose. Running bin/cucumber, for instance, is the equivalent of running bundle exec cucumber.
The generated bin directory should contain portable versions of the executables, so it should be safe to add them to version control.


Sponsor Ads

1 comment: