Skip to content

Commit 746a638

Browse files
committed
Fix broken testcase
1 parent f936cbb commit 746a638

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

Source/Alamofire-SwiftyJSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension DataRequest {
5959
-> DataResponseSerializer<JSON>
6060
{
6161
return DataResponseSerializer { _, response, data, error in
62-
return Request.serializeResponseSwiftyJSON(options: options, response: response, data: data, error: error)
62+
return Request.serializeResponseSwiftyJSON(options: options, response: response, data: data, error: error)
6363
}
6464
}
6565

Tests/Alamofire_SwiftyJSONTests.swift

+12-14
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,26 @@
66
// Copyright (c) 2014年 SwiftJSON. All rights reserved.
77
//
88

9-
import UIKit
109
import XCTest
1110
import Alamofire
1211
import SwiftyJSON
1312
import AlamofireSwiftyJSON
1413

1514
class Alamofire_SwiftyJSONTests: XCTestCase {
1615

17-
func testJSONResponse() {
16+
func testGETRequestJSONResponse() {
1817
let URL = "http://httpbin.org/get"
19-
let expectation = expectationWithDescription("\(URL)")
20-
21-
Alamofire.request(.GET, URL, parameters: ["foo": "bar"]).responseSwiftyJSON({(request, response, responseJSON, error) in
22-
expectation.fulfill()
23-
XCTAssertNotNil(request, "request should not be nil")
24-
XCTAssertNotNil(response, "response should not be nil")
25-
XCTAssertTrue(error == nil, "result error should be nil")
26-
XCTAssertEqual(responseJSON["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
27-
})
28-
waitForExpectationsWithTimeout(10) { (error) in
29-
XCTAssertNil(error, "\(error)")
18+
let parameters: Parameters = ["foo": "bar"]
19+
let expect = expectation(description: "responseSwiftyJSON method should work")
20+
Alamofire.request(URL, method: .get, parameters: parameters, encoding: URLEncoding.default)
21+
.validate()
22+
.responseSwiftyJSON { response in
23+
XCTAssertNotNil(response.request, "request should not be nil")
24+
XCTAssertNotNil(response.response, "response should not be nil")
25+
XCTAssertNil(response.error, "result error should be nil")
26+
XCTAssertEqual(response.value?["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
27+
expect.fulfill()
3028
}
29+
waitForExpectations(timeout: 10.0, handler: nil)
3130
}
32-
3331
}

0 commit comments

Comments
 (0)