This repository was archived by the owner on Nov 16, 2018. It is now read-only.
forked from cucumber/cucumber-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Patterns
tomtt edited this page Aug 13, 2010
·
22 revisions
A draft list of useful Cucumber patterns:
- XPath Sections
- Description: ability to scope an inspection or webrat step to a part of the html.
- Motivation: when an element appears at multiple locations in an html page you want the ability to specify which one a step refers to
- Examples:
Then I should see “logout” in the account section
When I follow “next” in the pagination section
- Implementation:
- Steps like
When /^I follow “([^\”])" in the (.)$/
- A mapping of section names to xpaths that can be used for scoping
- Webrat needs a patch to allow xpaths to be used
- Steps like
- Easy objects
- Description: generic step to create objects in a rails app
- Motivation: when writing cucumber for rails, you often want to create some objects and set their properties
- Examples:
Given the following People exist:
| name | date of birth |
| john | 20 Jan 1980 |
| mary | 10 days ago |
- Implementation:
- Generic step that has a model name and a table as arguments
- Factory used to create an object for each row with the properties defined in the table
- Transforms that map the properties to the correct type
- Relative times
- Manual steps
- Description: have a step that indicates an action that requires a human
- Motivation: some things can not be automatically tested (JS UI, captcha) and we still want cucumber to describe how the app should behave
- Examples:
Then /^.* \(manual step\)$/ do
end
And I fill in the captcha correctly (manual test)
- Implementation: define a step that matches anything and a unique string that denotes a manual step