Fixed conversion of GString to String; fixes gh-762

This commit is contained in:
Marcin Grzejszczak
2018-10-23 20:21:44 +02:00
parent 78048826a3
commit 38afb59076
3 changed files with 16 additions and 2 deletions

View File

@@ -101,6 +101,10 @@ class Request extends Common {
this.urlPath = new UrlPath(path)
}
void urlPath(GString path) {
this.urlPath = new UrlPath(path)
}
void urlPath(DslProperty path) {
this.urlPath = new UrlPath(path)
}
@@ -111,6 +115,12 @@ class Request extends Common {
closure()
}
void urlPath(GString path, @DelegatesTo(UrlPath) Closure closure) {
this.urlPath = new UrlPath(path)
closure.delegate = urlPath
closure()
}
void urlPath(DslProperty path, @DelegatesTo(UrlPath) Closure closure) {
this.urlPath = new UrlPath(path)
closure.delegate = urlPath

View File

@@ -35,6 +35,10 @@ class UrlPath extends Url {
super(path)
}
UrlPath(GString path) {
super(path)
}
UrlPath(DslProperty path) {
super(path)
}

View File

@@ -626,7 +626,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
Contract contractDsl = Contract.make {
request {
method 'GET'
urlPath('/users') {
urlPath("/users/${value(regex("1"))}") {
queryParameters {
parameter 'limit': $(consumer(equalTo("20")), producer(equalTo("10")))
parameter 'offset': $(consumer(containing("20")), producer(equalTo("20")))
@@ -665,7 +665,7 @@ class MockMvcMethodBodyBuilderSpec extends Specification implements WireMockStub
test.contains('''.queryParam("age","99")''')
test.contains('''.queryParam("name","Denis.Stepanov")''')
test.contains('''.queryParam("email","bob@email.com")''')
test.contains('''.get("/users")''')
test.contains('''.get("/users/1")''')
test.contains('assertThatJson(parsedJson).field("[\'property1\']").isEqualTo("a")')
test.contains('assertThatJson(parsedJson).field("[\'property2\']").isEqualTo("b")')
and: