Ensures that regex is asserted also for RegexProperty not only Pattern
fixes gh-1200
This commit is contained in:
@@ -244,6 +244,14 @@ class Common {
|
||||
assert value ==~ pattern
|
||||
}
|
||||
|
||||
void assertThatSidesMatch(RegexProperty pattern, String value) {
|
||||
assert value ==~ pattern.pattern
|
||||
}
|
||||
|
||||
void assertThatSidesMatch(String value, RegexProperty pattern) {
|
||||
assert value ==~ pattern.pattern
|
||||
}
|
||||
|
||||
void assertThatSidesMatch(MatchingStrategy firstSide, MatchingStrategy secondSide) {
|
||||
if (firstSide.type == MatchingStrategy.Type.ABSENT && secondSide.type != MatchingStrategy.Type.ABSENT) {
|
||||
throwAbsentError()
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.contract.spec.internal
|
||||
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
|
||||
import org.springframework.cloud.contract.spec.Contract
|
||||
@@ -422,4 +423,23 @@ then:
|
||||
expect:
|
||||
contract != null
|
||||
}
|
||||
|
||||
@Issue("1200")
|
||||
def 'should fail when regex do not match the concrete value'() {
|
||||
when:
|
||||
Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url '/any'
|
||||
}
|
||||
response {
|
||||
status OK()
|
||||
body([
|
||||
time: $(p(regex(iso8601WithOffset())),c( "thisIsNotADate"))
|
||||
])
|
||||
}
|
||||
}
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user