i am able to mock using mock service as below but when i try to verify the mock against the provider, it is throwing error. i am suspecting because of date values.can you please help me what might be the issue
Mock Jason file :
@Mattthew - Thank you for looking into it . i have cleaned up mock up by re running the mock . instead of mocking total service response, i did mock only one item.
Mocking Code :
'url = 'http://localhost:1234'
expected = {'class': 'HealthCheck'}
Mock JSON :
'{
"consumer": {
"name": "consumer"
},
"provider": {
"name": "provider"
},
"interactions": [
{
"description": "a request for the health check",
"providerState": "the health of the system is OK",
"request": {
"method": "get",
"path": "/"
},
"response": {
"status": 200,
"headers": {
},
"body": {
"class": "HealthCheck"
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
}'
Real Service Provider Response :
'{
"class": [
"HealthCheck"
],
"properties": {
"timestamp": "2018-08-01T00:10:00+0000",
"systemName": "Test",
"buildInfo": {
"buildDate": "2018-07-27T07:38:19+0000",
"appVersion": "1111",
"revision": "2 ",
"branch": "develop"
},
"health": "OK",
"checks": []
},
"links": [
{
"rel": [
"self"
],
"href": " check"
}
]
}'
Error when i running against real provider : 1) Verifying a pact between consumer and provider Given the health of the system is OK a request for the check with GET / returns a response which has a matching body Failure/Error: expect(response_body).to match_term expected_response_body, diff_options Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8
Could it be this line?
What is the stuff inside the back ticks? It doesn't appear to be valid JSON - did you modify it by hand?
Also, not sure it's intentional, but there also appears to be a lot of unnecessary spaces in your values. Might be worth checking that too.