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
Here's a fun one. I'm creating a stub to catch an upload request that I create using AFNetworking's -[NSURLSessionManager uploadTaskWithRequest:fromData:progress:completionHandler:] method. Here's my stub:
When I run the test, an exception is thrown in -[OHHTTPStubs startLoading] at this assertion:
NSAssert(stub, @"At the time startLoading is called, canInitRequest should have assured that stub is != nil beforehand");
Back in the stub, if I simply return YES in the request test block so that all requests pass, this exception is still thrown. If I place a breakpoint in this block and look at request, I see that two requests hit the block--the one I expect, and a nil request. Strangely, when I place a breakpoint, run the test, hit the breakpoint, and continue in the debugger through each request, the test passes and no exception is thrown.
The text was updated successfully, but these errors were encountered:
I see now that if I remove the stub after all tests, instead of after each test (even though there is only one test!), I have no problems running this test.
That's indeed a strange one! I'll try to find some time next week to investigate a bit why you have a nil request (even if I'm not sure I have any leverage on this, as this is the responsibility of the OS itself).
Anyway, please note that as explained here in the README, OHHTTPStubs uses NSURLProtocolClient to catch the network requests and this Apple class does not allow us to catch upload requests, so unfortunately those can't be stubbed.
Here's a fun one. I'm creating a stub to catch an upload request that I create using AFNetworking's
-[NSURLSessionManager uploadTaskWithRequest:fromData:progress:completionHandler:]
method. Here's my stub:Here's my test:
And here's that
-sendNewSplashData...
method:When I run the test, an exception is thrown in
-[OHHTTPStubs startLoading]
at this assertion:Back in the stub, if I simply return
YES
in the request test block so that all requests pass, this exception is still thrown. If I place a breakpoint in this block and look atrequest
, I see that two requests hit the block--the one I expect, and a nil request. Strangely, when I place a breakpoint, run the test, hit the breakpoint, and continue in the debugger through each request, the test passes and no exception is thrown.The text was updated successfully, but these errors were encountered: