TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Aug 2016 |
Maintained by hypoyao.
Library for replacing part/all HTTP response based on Nocilla.
mocking a request before the real request anywhere.
It will return the default response, which is a 200 and an empty body.
mockRequest(@"GET", @"http://www.google.com");
mockRequest(@"GET", @"(.*?)google.com(.*?)".regex).
withBody(@"{\"name\":\"abc\"}".regex);
mockRequest(@"POST", @"http://www.google.com").
isUpdatePartResponseBody(YES).
withBody(@"{\"name\":\"abc\"}".regex);
andReturn(200).
withBody(@"{\"key\":\"value\"}");
mockRequest(@"POST", @"http://www.google.com").
isUpdatePartResponseBody(YES).
withBody(@"{\"name\":\"abc\"}".regex);
andReturn(200).
withBody(@"google.json");
orginal response:
{"data":{"id":"abc","location":"GZ"}}
updatedBody: google.json
{"data":{"time":"today"}}
final resoponse:
{"data":{"id":"abc","location":"GZ","time":"today"}}
mockRequest(@"POST", @"http://www.google.com").
withHeaders(@{@"Accept": @"application/json"}).
withBody(@"\"name\":\"foo\"".regex).
isUpdatePartResponseBody(YES).
andReturn(200).
withHeaders(@{@"Content-Type": @"application/json"}).
withBody(@"google.json");
GYHttpMock is released under the MIT license. See LICENSE for details.