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

Writing Cucumber Features

In Cucumber you write tests as a series of steps using a very minimal language called Gherkin. An individual Cucumber test is called a Scenario, and a group of them is called a Feature.

Let’s take the Capybara integration test from the last section and convert it to Cucumber. Cucumber feature files go in the features directory and typically end in .feature. Here is features_add_task.feature:

integration/03/gatherer/features/add_task.feature
 
Feature:​ Adding a task​​
 
​​
 
Background:​​​
 
Given ​a project​​
 
​​
 
Scenario:​ I can add and change priority of a new task​​
 
When ​I visit the project page​​
 
And ​I complete the new task form​​
 
Then ​I am back on the project page​​
 
And ​I see the new task is ...

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