Skip to content

Instantly share code, notes, and snippets.

@andymedvedev
Created May 10, 2016 06:08
Show Gist options
  • Save andymedvedev/a72f65458542149f57f22974d63b312d to your computer and use it in GitHub Desktop.
Save andymedvedev/a72f65458542149f57f22974d63b312d to your computer and use it in GitHub Desktop.
Stubbing not working with Alamofire manager
func testExample() {
let expectation = expectationWithDescription("test expectation")
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.timeoutIntervalForRequest = 30
let alamofireManager = Manager(configuration: configuration)
let body = ["json": "test"]
stub(everything, builder: json(body))
alamofireManager.request(.GET, "https://www.test.com").responseJSON { response in
switch response.result {
case .Success(let JSON):
print(JSON)
expectation.fulfill()
case .Failure(let error):
print(error)
}
}
waitForExpectationsWithTimeout(5.0, handler: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment