Stubbing Google Maps/Places iOS SDK calls for unit testing

233 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

Answer given here: (I was using the incorrect host name, should use simply "www.googleapis.com")

https://github.com/AliSoftware/OHHTTPStubs/issues/219