Skip to content

Commit

Permalink
docs(collect): document data collection & reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed Jun 28, 2017
1 parent e793280 commit 0adbd66
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,32 @@ Scenario: Using GitHub API
Then I should receive a 200 HTTP status code
```

#### Using values issued by a previous request

Imagine you want to test a resource creation and then that you're able
to fetch this new entity through the API.

If resource id is generated by your API, it will be impossible to make
the second call because id is unknown.

To solve this problem you have the ability to collect data from
a previous response, store it in the state and inject it at various
places using placeholders.

The following example calls the root GitHub API endpoint,
extracts the `emojis_url` value from the json response and
stores it in the current state under the `emojisUrl` key,
then it uses this value to make its next request.

``` gherkin
Scenario: Using GitHub API
Given I set User-Agent request header to veggies/1.0
When I GET https://api.github.com/
And I pick response json emojis_url as emojisUrl
And I GET {{emojisUrl}}
Then I should receive a 200 HTTP status code
```

[npm-image]: https://img.shields.io/npm/v/@ekino/veggies.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/@ekino/veggies
[travis-image]: https://img.shields.io/travis/ekino-node-staging/veggies.svg?style=flat-square
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"check-fmt": "prettier --print-width 140 --tab-width=4 --single-quote --bracket-spacing --no-semi --list-different \"src/**/*.js\"",
"version": "echo ${npm_package_version}",
"lint": "eslint .",
"examples": "cucumberjs --require examples/support ${args} examples/features"
"examples": "cucumberjs --require examples/support examples/features"
}
}

0 comments on commit 0adbd66

Please sign in to comment.