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