Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created June 18, 2020 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/fc39c2ee383b4b70a5cbc11fbd3c5645 to your computer and use it in GitHub Desktop.
Save stevencurtis/fc39c2ee383b4b70a5cbc11fbd3c5645 to your computer and use it in GitHub Desktop.
URLProtocolMockInstance
let data = jsonString.data(using: .utf8)
URLProtocolMock.requestHandler = { request in
let response = HTTPURLResponse(url: URL(fileURLWithPath: ""), statusCode: 200, httpVersion: nil, headerFields: nil)!
return (response, data)
}
let configuration = URLSessionConfiguration.af.default
configuration.protocolClasses = [URLProtocolMock.self] + (configuration.protocolClasses ?? [])
let session = Session(configuration: configuration)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment