Skip to content

Commit

Permalink
add doc for response pass along to next request
Browse files Browse the repository at this point in the history
  • Loading branch information
JakimLi committed Nov 4, 2018
1 parent ef99289 commit 7e9b580
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Table of Contents
* [In Code Evaluation](#in-code-evaluation)
* [Escape](#escape)
* [Special variable with Faker](#special-variable-with-faker)
* [Special variable with last response](#special-variable-with-last-response)

* [Verification](#verification)
* [Verify http response](#verify-http-response)
Expand Down Expand Up @@ -810,6 +811,59 @@ In above example, name will be set to a fake name, but city will be set to `#{Ad
**will not work, use `var: 'name'='#{Name.fullName}'` instead.**


### Special variable with last response
@since 0.2.3

It's useful that you can use part of or whole http response as next request body. you can use `@{<json path>}` in your
next request body, Pandaria will replace it for you. Works in file as well.

Whole response for next request

```gherkin
* uri: /users/me
* send: get
* verify: '$.username'='jakim'
* verify: '$.age'=18
* verify: '$.iq'=double: 80.0
* uri: /users
* request body:
"""
@{$}
"""
* send: POST
* status: 200
* verify: '$.id'='auto-generated'
* verify: '$.username'='jakim'
* verify: '$.age'=18
```

Part of the response for next request

```gherkin
* uri: /users/me
* send: get
* verify: '$.username'='jakim'
* verify: '$.age'=18
* verify: '$.iq'=double: 80.0
* uri: /users
* request body:
"""
{ "username": @{$.username}}
"""
* send: POST
* status: 200
* verify: '$.id'='auto-generated'
* verify: '$.username'='jakim'
* verify: '$.age'=18
```

**Please be careful about the double quotes, because Pandaria assumes the value of json path expression is also a JSON,**
**so it will automatically handle double quotes, with variables in `${}` or faker expresson `#{}`, you will need to handle**
**double quotes yourself**


Verification
-----------

Expand Down

0 comments on commit 7e9b580

Please sign in to comment.