Recipe 4 | Refactor to Extract Your Own Application Driver DSL |
Problem
Your step definition code is growing out of control. When you jump down the stack from your nice, readable Cucumber scenarios into the step definitions behind them, you’re suddenly besieged by masses of Ruby code. You have a nagging feeling that there are little bits of duplication all over the place, but you just can’t see it. You need to clean things up.
Ingredients
-
Ruby’s built-in module[28] mixins
-
Cucumber’s built-in World method[29] for registering extension modules
-
The capybara gem[30] for automating browsers
-
The Firefox web browser[31]
Solution
In this recipe, we’ll start with an existing Cucumber scenario for testing a website. The step definitions are difficult ...
Get Cucumber Recipes 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.