You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a few tests using OHHTTPStubs in my project, and some of them fail because the stub is not called. I know they are not called because a breakpoint on the response block does not pause the execution, and because RestKit complains about the fake URL.
I'm using OHHTTPStubs 3.1.2 installed via CocoaPods, RestKit 0.9.3 (quite old but updating is not possible right now), iOS 7.1 and XCode 5.1.1.
Here's the code of one test that fails:
- (void)testRetrievePlatformInfo
{
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
returnYES;
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
return [OHHTTPStubsResponse responseWithFileAtPath:OHPathForFileInBundle(@"PlatformInfoResponse-4.0.json", nil) statusCode:200headers:[NSDictionarydictionaryWithObject:@"application/json"forKey:@"Content-Type"]];
}].name = @"Platform Information";
[loginProxy retrievePlatformInformations];
NSLog(@"All stubs: %@", [OHHTTPStubs allStubs]);
// Wait for the asynchronous code to finish, or a 5s timeoutNSDate* timeoutDate = [NSDatedateWithTimeIntervalSinceNow:5];
responseArrived = NO;
while (!responseArrived && ([timeoutDate timeIntervalSinceNow]>0))
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.01, YES);
// some assertions
}
My test class implements delegate methods for handling the response, one for success and one for error. Indeed the error method is called immediately:
2014-06-09 17:42:29.714 eXo[30966:60b] C restkit.network:RKRequest.m:349 SharedClient = <RKClient: 0x9815e90> and network availability = 0
2014-06-09 17:42:50.687 eXo[30966:60b] ERROR: Error Domain=com.twotoasters.RestKit.ErrorDomain Code=2 "The client is unable to contact the resource at http://demo.platform.exo.org/rest/platform/info" UserInfo=0x9816560 {NSLocalizedDescription=The client is unable to contact the resource at http://demo.platform.exo.org/rest/platform/info}
Elsewhere in the code I am logging when stubs are activated
Although RestKit is based on NSURLConnection, when I test another method which sends a request with NSURLConnection directly, this request is stubbed properly...
Finally, I have checked the similar issues #37#42 and #47 , simplified my Podfile to the maximum, etc but it didn't help.
I am clueless, I might isolate the test case in a separate project for you to see the whole picture, and start upgrading RK if that helps, but meanwhile any idea on this issue would be appreciated.
Cheers,
Philippe
The text was updated successfully, but these errors were encountered:
I've been able to fix my tests by using a real base URL instead of a fake one.
What I think was happening is that RestKit does a reachability test before calling the rest services, and I guess (but not sure) that it happens before stubs are registered.
I'm trying to find more details but it does not seem to be an issue with OHHTTPStubs anyways.
I tried to display the network requests with tcpdump, but nothing appeared. Either my filter was incorrect, or there's something else. I could try with my own server and reading the logs but I don't have so much time so I'll leave it for later.
Hi,
I have a few tests using OHHTTPStubs in my project, and some of them fail because the stub is not called. I know they are not called because a breakpoint on the response block does not pause the execution, and because RestKit complains about the fake URL.
I'm using OHHTTPStubs 3.1.2 installed via CocoaPods, RestKit 0.9.3 (quite old but updating is not possible right now), iOS 7.1 and XCode 5.1.1.
Here's the code of one test that fails:
The line
[loginProxy retrievePlatformInformations];
calls this method
Displaying the registered stubs shows that it is OK so far:
My test class implements delegate methods for handling the response, one for success and one for error. Indeed the error method is called immediately:
Elsewhere in the code I am logging when stubs are activated
and surely nothing is logged.
Although RestKit is based on NSURLConnection, when I test another method which sends a request with NSURLConnection directly, this request is stubbed properly...
Finally, I have checked the similar issues #37 #42 and #47 , simplified my Podfile to the maximum, etc but it didn't help.
I am clueless, I might isolate the test case in a separate project for you to see the whole picture, and start upgrading RK if that helps, but meanwhile any idea on this issue would be appreciated.
Cheers,
Philippe
The text was updated successfully, but these errors were encountered: