O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting Up Cucumber

To install Cucumber, we need two gems in the Gemfile:

 
group :development, :test ​do
 
gem ​'cucumber-rails'​, require: false ​# The false prevents a warning
 
gem ​'database_cleaner'
 
end

Then bundle install.

Strictly speaking, database_cleaner isn’t required, but it’s valuable and gives fixture-like transaction behavior to your nonfixture using tests. The cucumber gem will be installed as a dependency of cucumber-rails. As I write this, we’re talking about version 1.3.15 of Cucumber and version 1.4.1 of cucumber_rails.

To install Cucumber, there’s a command-line generator:

 
rails generate cucumber:install

This creates a config/cucumber.yml file for runtime options, the actual cucumber command-line script, a rake

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required