Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stubs request tests pass, but stubs response block not called #46

Closed
sibljon opened this issue Dec 19, 2013 · 2 comments
Closed

Stubs request tests pass, but stubs response block not called #46

sibljon opened this issue Dec 19, 2013 · 2 comments

Comments

@sibljon
Copy link

sibljon commented Dec 19, 2013

Hi,

Here's my setup for the stubbing:

id<OHHTTPStubsDescriptor> stub = [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {

    return [request.URL.absoluteString containsString:kVisitReviewPath];

} withStubResponse:^OHHTTPStubsResponse*(NSURLRequest *request) {

    return [OHHTTPStubsResponse responseWithFileAtPath:OHPathForFileInBundle(@"patient_visit_review.json",nil)
                                            statusCode:200
                                               headers:@{@"Content-Type":@"text/json"}];
}];

This test is being passed multiple times (I'm breaking on firstStubPassingTestForRequest: and foundStub always contains the exact OHHTTPStubsDescriptor I'm expecting); however, the stub response block never gets called.

Here's what I've verified so far, based on reading the Github Issue history of this repo:

  1. setEnabled: gets called with YES, so OHHTTPStubsProtocol gets registered
  2. I'm using AFNetworking 2.0, and NSURLSession is initialized with [NSURLSessionConfiguration defaultSessionConfiguration]
  3. There is only one singleton instance of OHHTTPStubs being used

Does anyone have any idea where I can look next to keep debugging?

@AliSoftware
Copy link
Owner

Are you sure OHPathForFileInBundle(@"patient_visit_review.json",nil) return the path where you expect your json file to be, and that this file is correctly included in you test target so is included in your bundle when you build it for the test target?

If you create an OHHTTPStubsResponse with no data that would explain why you never get your response. Did you put a breakpoint in the response block somewhere at least?

@sibljon
Copy link
Author

sibljon commented Dec 26, 2013

@AliSoftware Your suspicious were correct: the file patient_visit_review.json wasn't included in the test target. Thanks for your response, and sorry to waste your time... Hopefully someone in the future will find this thread helpful to make up for that!

Oh, and I almost forgot to thank you for such a wonderful library.

@sibljon sibljon closed this as completed Dec 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants