Created
May 10, 2016 06:08
-
-
Save andymedvedev/a72f65458542149f57f22974d63b312d to your computer and use it in GitHub Desktop.
Stubbing not working with Alamofire manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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