Configure Grails sample to run tests using a random server port
See gh-250
This commit is contained in:
@@ -74,6 +74,8 @@ environments:
|
||||
dataSource:
|
||||
dbCreate: update
|
||||
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
|
||||
server:
|
||||
port: 0
|
||||
production:
|
||||
dataSource:
|
||||
dbCreate: update
|
||||
|
||||
@@ -35,8 +35,9 @@ import com.jayway.restassured.specification.RequestSpecification
|
||||
import grails.test.mixin.integration.Integration
|
||||
import grails.transaction.Rollback
|
||||
import org.junit.Rule
|
||||
import org.springframework.restdocs.JUnitRestDocumentation
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.restdocs.JUnitRestDocumentation
|
||||
import spock.lang.Specification
|
||||
|
||||
@Integration
|
||||
@@ -46,6 +47,9 @@ class ApiDocumentationSpec extends Specification {
|
||||
@Rule
|
||||
JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation('src/docs/generated-snippets')
|
||||
|
||||
@Value('${local.server.port}')
|
||||
Integer serverPort
|
||||
|
||||
protected RequestSpecification documentationSpec
|
||||
|
||||
void setup() {
|
||||
@@ -75,7 +79,7 @@ class ApiDocumentationSpec extends Specification {
|
||||
fieldWithPath('plugins').type(JsonFieldType.ARRAY).description('the plugins active for this project'),
|
||||
)))
|
||||
.when()
|
||||
.port(8080)
|
||||
.port(this.serverPort)
|
||||
.get('/')
|
||||
.then()
|
||||
.assertThat()
|
||||
@@ -99,7 +103,7 @@ class ApiDocumentationSpec extends Specification {
|
||||
fieldWithPath('[].tags').type(JsonFieldType.ARRAY).description('the list of tags associated with the note'),
|
||||
)))
|
||||
.when()
|
||||
.port(8080)
|
||||
.port(this.serverPort)
|
||||
.get('/notes')
|
||||
.then()
|
||||
.assertThat()
|
||||
@@ -130,7 +134,7 @@ class ApiDocumentationSpec extends Specification {
|
||||
)))
|
||||
.body('{ "body": "My test example", "title": "Eureka!", "tags": [{"name": "testing123"}] }')
|
||||
.when()
|
||||
.port(8080)
|
||||
.port(this.serverPort)
|
||||
.post('/notes')
|
||||
.then()
|
||||
.assertThat()
|
||||
@@ -154,7 +158,7 @@ class ApiDocumentationSpec extends Specification {
|
||||
fieldWithPath('tags').type(JsonFieldType.ARRAY).description('the list of tags associated with the note'),
|
||||
)))
|
||||
.when()
|
||||
.port(8080)
|
||||
.port(this.serverPort)
|
||||
.get('/notes/1')
|
||||
.then()
|
||||
.assertThat()
|
||||
|
||||
Reference in New Issue
Block a user