To install Cucumber, first add the cucumber-rails gem and a utility gem called database_cleaner to the :test group in the Gemfile
. . group :test do . . . gem 'cucumber-rails', '1.4.0', :require => false gem 'database_cleaner', github: 'bmabey/database_cleaner' end . .
Then run these two following commands in your project directory through terminal:
$ bundle install $ rails generate cucumber:install
This creates a features/ directory where the files associated with Cucumber will live.
Example cucumber feature:
Feature: Signing in Scenario: Unsuccessful signin Given a user visits the signin page When he submits invalid signin information Then he should see an error message Scenario: Successful signin Given a user visits the signin page And the user has an account When the user submits valid signin information Then he should see his profile page And he should see a signout link
To run the features, we use the cucumber executable:
$ bundle exec cucumber features/
$ bundle exec rake cucumber