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 ...

Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.