Updated docs (#48)

* Added docs + tests for spec
* Updated WireMock tests for docs
* Made wiremock tests dynamic
This commit is contained in:
Marcin Grzejszczak
2016-07-22 14:07:44 +02:00
committed by GitHub
parent cc1d20c91b
commit 70acffd9e6
10 changed files with 368 additions and 40 deletions

View File

@@ -0,0 +1,80 @@
package org.springframework.cloud.contract.spec.internal
import org.springframework.cloud.contract.spec.Contract
import spock.lang.Specification
/**
* @author Marcin Grzejszczak
*/
class ContractSpec extends Specification {
def 'should work for http'() {
when:
Contract.make {
request {
url('/foo')
method('PUT')
headers {
header([
foo: 'bar'
])
}
body([
foo: 'bar'
])
}
response {
headers {
header([
foo2: 'bar'
])
}
body([
foo2: 'bar'
])
}
}
then:
noExceptionThrown()
}
def 'should work for messaging'() {
when:
Contract.make {
input {
messageFrom('input')
messageBody([
foo: 'bar'
])
messageHeaders {
header([
foo: 'bar'
])
}
}
outputMessage {
sentTo('output')
body([
foo2: 'bar'
])
headers {
header([
foo2: 'bar'
])
}
}
}
then:
noExceptionThrown()
}
def 'should generate a value if only regex is passed for client'() {
given:
Request request = new Request()
DslProperty property
when:
request.with {
property = value(consumer(regex("[0-9]{5}")))
}
then:
(property.serverValue as String).matches(/[0-9]{5}/)
}
}