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:

Feature:​ Adding a task​​
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 ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.