Added regex escaping for request body matching

This commit is contained in:
Jakub Kubrynski
2015-01-29 00:20:19 +01:00
parent d50d56dff2
commit 76ffce6fc4
2 changed files with 4 additions and 2 deletions

View File

@@ -23,7 +23,9 @@ class SpockMethodBodyBuilder {
blockBuilder.addLine(".header('$it.key', '$it.value.equalTo')")
}
if (stubDefinition.request.bodyPatterns) {
blockBuilder.addLine(".body('${JsonOutput.toJson(stubDefinition.request.bodyPatterns[0].matches)}')")
String matches = stubDefinition.request.bodyPatterns[0].matches
matches = matches.replaceAll('\\\\', '');
blockBuilder.addLine(".body('${JsonOutput.toJson(matches)}')")
}
blockBuilder.unindent().endBlock().addEmptyLine()

View File

@@ -9,7 +9,7 @@
},
"bodyPatterns": [
{
"matches": "{\"client\":{\"pesel\":\"1234567890\"},\"loanApplicationId\":123123123,\"amount\":123.123}"
"matches": "\\{\"clientPesel\":\"1234567890\",\"loanAmount\":123.123\\}"
}
]
},