AliSoftware / OHHTTPStubs

Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
MIT License
5.03k stars 601 forks source link

Using with Google Maps iOS SDK #219

Closed zachlucas closed 7 years ago

zachlucas commented 7 years ago

I'm trying to stub my Google Places calls using a local json file. Using Charles proxy, I find that the Google Maps SDK uses the url https://www.googleapis.com. So, I try to stub like:

stub(isHost("https://www.googleapis.com")) { request in
   OHHTTPStubsResponse(fileAtPath: "google_maps.json", statusCode: 200, headers: ["Content-Type":"application/json"])
}

But it's not intercepting the google maps SDK calls. Any ideas? Could this be the Google Maps SDK using something other than Cocoa's URL Loading System?

AliSoftware commented 7 years ago

https://www.googleapis.com" is not a host. That a full URL. The host of this URL (as returned by NSURL(string: "https://www.googleapis.com")!.host for example) is just www.googleapis.com.

zachlucas commented 7 years ago

Thank you, that was my issue.