Mockingjay icon indicating copy to clipboard operation
Mockingjay copied to clipboard

Matching GET requests with query

Open willm opened this issue 8 years ago • 0 comments

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)

willm avatar Nov 30 '17 09:11 willm