Fix #24 - GroovyDSL -> JSON - issue with new lines

This commit is contained in:
Jakub Kubrynski
2015-02-21 13:16:04 +01:00
parent 4a5efff48c
commit 614f5438a8
2 changed files with 43 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ class Body {
}
Body(Object bodyAsValue) {
this.bodyAsValue = new DslProperty(bodyAsValue)
this("${bodyAsValue}")
}
Body(GString bodyAsValue) {

View File

@@ -108,6 +108,48 @@ class WiremockGroovyDslSpec extends Specification {
''')
}
def 'should convert groovy dsl stub with simple Body as String to wiremock stub for the client side'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {
request {
method('GET')
urlPattern $(client('/[0-9]{2}'), server('/12'))
}
response {
status 200
body("""\
{
"name": "Jan"
}
"""
)
headers {
header 'Content-Type': 'text/plain'
}
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
"urlPattern": "/[0-9]{2}"
},
"response": {
"status": 200,
"body": {
"name": "Jan"
},
"headers": {
"Content-Type": "text/plain"
}
}
}
''')
}
def 'should convert groovy dsl stub with Body as String to wiremock stub for the server side'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {