Added docs

This commit is contained in:
Marcin Grzejszczak
2018-04-11 12:34:23 +02:00
parent d203fe8dea
commit 6ace68284c
4 changed files with 63 additions and 4 deletions

View File

@@ -257,6 +257,22 @@ include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=request,i
include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=headers,indent=0]
----
`request` may contain additional **request cookies**, as shown in the following example:
.Groovy DSL
[source,groovy,indent=0]
----
include::{verifier_core_path}/src/test/groovy/org/springframework/cloud/contract/verifier/builder/ContractHttpDocsSpec.groovy[tags=cookies,indent=0]
----
.YAML
[source,yml,indent=0]
----
include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=request,indent=0]
...
include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=cookies,indent=0]
----
`request` may contain a **request body**:
.Groovy DSL
@@ -357,8 +373,7 @@ include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=response,
include::{verifier_core_path}/src/test/resources/yml/contract.yml[tags=response_obligatory,indent=0]
----
Besides status, the response may contain **headers** and a **body**, both of which are
Besides status, the response may contain **headers**, **cookies** and a **body**, both of which are
specified the same way as in the request (see the previous paragraph).
=== Dynamic properties

View File

@@ -153,6 +153,28 @@ class ContractHttpDocsSpec extends Specification {
}
// end::headers[]
org.springframework.cloud.contract.spec.Contract cookies =
// tag::cookies[]
org.springframework.cloud.contract.spec.Contract.make {
request {
//...
// Each Cookies is added in form `'Cookie-Key' : 'Cookie-Value'`.
// there are also some helper methods
cookies {
cookie 'key': 'value'
cookie('another_key', 'another_value')
}
//...
}
response {
//...
}
}
// end::cookies[]
org.springframework.cloud.contract.spec.Contract body =
// tag::body[]
org.springframework.cloud.contract.spec.Contract.make {

View File

@@ -27,6 +27,11 @@ request:
foo: bar
fooReq: baz
#end::headers[]
#tag::cookies[]
cookies:
foo: bar
fooReq: baz
#end::cookies[]
#tag::body[]
body:
foo: bar
@@ -66,4 +71,9 @@ response:
- key: foo2
regex: bar
- key: foo3
command: andMeToo($it)
command: andMeToo($it)
cookies:
- key: foo2
regex: bar
- key: foo3
predefined:

View File

@@ -24,6 +24,11 @@ response:
fooRes: baz
body:
foo2: bar
cookies:
foo: baz
fooRegex: 123
source: ip_address
fooPredefinedRegex: true
matchers:
body:
- path: $.foo2
@@ -31,4 +36,11 @@ response:
value: bar
headers:
- key: foo2
regex: bar
regex: bar
cookies:
- key: fooRegex
regex: "[0-9]+"
- key: source
regex: ip_address
- key: fooPredefinedRegex
predefined: any_boolean