1
1
package au.com.dius.pact.core.matchers
2
2
3
3
import spock.lang.Specification
4
- import spock.lang.Unroll
5
4
import spock.util.environment.RestoreSystemProperties
6
5
7
6
@RestoreSystemProperties
8
7
class MatchingConfigSpec extends Specification {
9
8
10
- def setupSpec () {
11
- System . setProperty(' pact.content_type.override.application/x-thrift' , ' json' )
12
- System . setProperty(' pact.content_type.override.application/x-other' , ' text' )
13
- }
14
-
15
- @Unroll
16
9
def ' maps JSON content types to JSON body matcher' () {
17
10
expect :
18
11
MatchingConfig . lookupContentMatcher(contentType). class. name == matcherClass
@@ -26,7 +19,21 @@ class MatchingConfigSpec extends Specification {
26
19
' application/stuff+xml' | ' au.com.dius.pact.core.matchers.XmlContentMatcher'
27
20
' application/json-rpc' | ' au.com.dius.pact.core.matchers.JsonContentMatcher'
28
21
' application/jsonrequest' | ' au.com.dius.pact.core.matchers.JsonContentMatcher'
22
+ }
23
+
24
+ def ' allows content type matchers to be overridden' () {
25
+ given :
26
+ System . setProperty(' pact.content_type.override.application/x-thrift' , ' json' )
27
+ System . setProperty(' pact.content_type.override.application/x-other' , ' text' )
28
+ System . setProperty(' pact.content_type.override.text/plain' , ' application/xml' )
29
+
30
+ expect :
31
+ MatchingConfig . lookupContentMatcher(contentType). class. name == matcherClass
32
+
33
+ where :
34
+ contentType | matcherClass
29
35
' application/x-thrift' | ' au.com.dius.pact.core.matchers.JsonContentMatcher'
30
36
' application/x-other' | ' au.com.dius.pact.core.matchers.PlainTextContentMatcher'
37
+ ' text/plain' | ' au.com.dius.pact.core.matchers.XmlContentMatcher'
31
38
}
32
39
}
0 commit comments