@@ -35,8 +35,9 @@ import com.jayway.restassured.specification.RequestSpecification
3535import grails.test.mixin.integration.Integration
3636import grails.transaction.Rollback
3737import org.junit.Rule
38- import org.springframework.restdocs.JUnitRestDocumentation
38+ import org.springframework.beans.factory.annotation.Value
3939import org.springframework.http.MediaType
40+ import org.springframework.restdocs.JUnitRestDocumentation
4041import spock.lang.Specification
4142
4243@Integration
@@ -46,6 +47,9 @@ class ApiDocumentationSpec extends Specification {
4647@Rule
4748JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation (' src/docs/generated-snippets' )
4849
50+ @Value (' ${local.server.port}' )
51+ Integer serverPort
52+
4953protected RequestSpecification documentationSpec
5054
5155void setup () {
@@ -75,7 +79,7 @@ class ApiDocumentationSpec extends Specification {
7579fieldWithPath(' plugins' ). type(JsonFieldType . ARRAY ). description(' the plugins active for this project' ),
7680)))
7781.when()
78- .port(8080 )
82+ .port(this . serverPort )
7983.get(' /' )
8084.then()
8185.assertThat ()
@@ -99,7 +103,7 @@ class ApiDocumentationSpec extends Specification {
99103fieldWithPath(' [].tags' ). type(JsonFieldType . ARRAY ). description(' the list of tags associated with the note' ),
100104)))
101105.when()
102- .port(8080 )
106+ .port(this . serverPort )
103107.get(' /notes' )
104108.then()
105109.assertThat ()
@@ -130,7 +134,7 @@ class ApiDocumentationSpec extends Specification {
130134)))
131135.body(' { "body": "My test example", "title": "Eureka!", "tags": [{"name": "testing123"}] }' )
132136.when()
133- .port(8080 )
137+ .port(this . serverPort )
134138.post(' /notes' )
135139.then()
136140.assertThat ()
@@ -154,7 +158,7 @@ class ApiDocumentationSpec extends Specification {
154158fieldWithPath(' tags' ). type(JsonFieldType . ARRAY ). description(' the list of tags associated with the note' ),
155159)))
156160.when()
157- .port(8080 )
161+ .port(this . serverPort )
158162.get(' /notes/1' )
159163.then()
160164.assertThat ()
0 commit comments