Mockingjay
Mockingjay copied to clipboard
Matching GET requests with query
Is it possible to stub requests with specific query strings?
The following works fine (note the absence of a query string in the call to stub:
stub(http(.get, uri: "/test?id=123"), json(["check": "ok"], status: 200))
var request = URLRequest(url: URL(string: "http://somehost.com/test?id=123")!)
request.httpMethod = "GET"
var match = http(.get, uri: "/test")(request)
XCTAssertTrue(match)
However adding a query to the uri in the call to stub fails:
stub(http(.get, uri: "/test?id=123"), json(["check": "ok"], status: 200))
var request = URLRequest(url: URL(string: "http://somehost.com/test?id=123")!)
request.httpMethod = "GET"
var match = http(.get, uri: "/test?id=123")(request)
XCTAssertTrue(match)