Writing Cucumber Features

In Cucumber you write tests as a series of steps using a 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
 
  Background:
  Given a project
 
  Scenario: I can add and change the 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 last in the list
  When I click to move the ...

Get Rails 5 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.