Made the tests less brittle

This commit is contained in:
Marcin Grzejszczak
2017-01-26 12:20:01 +01:00
parent 374a9916ed
commit c8784dccac
2 changed files with 10 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ class AssertionUtil {
private static boolean NON_STRICT = false
public static void assertThatJsonsAreEqual(String expected, String actual) {
static void assertThatJsonsAreEqual(String expected, String actual) {
JSONAssert.assertEquals(expected, actual, NON_STRICT)
}
}

View File

@@ -200,7 +200,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
when:
String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
def actual = new JsonSlurper().parseText(wireMockStub)
def expected = new JsonSlurper().parseText('''
{
"request" : {
"urlPattern" : "/[0-9]{2}",
@@ -214,7 +215,13 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
}
}
'''), wireMockStub)
''')
actual.request == expected.request
actual.response.status == expected.response.status
actual.response.headers == expected.response.headers
def actualBody = new JsonSlurper().parseText(actual.response.body)
def expectedBody = new JsonSlurper().parseText(expected.response.body)
actualBody == expectedBody
and:
stubMappingIsValidWireMockStub(wireMockStub)
}