TinkoffMockStrapping is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TinkoffMockStrapping', :git => 'https://github.com/tinkoff-mobile-tech/TinkoffMockStrapping.git'
If you want to use TinkoffMockStrapping with Swifter, add the following line to your Podfile:
pod 'TinkoffMockStrapping/Swifter', :git => 'https://github.com/tinkoff-mobile-tech/TinkoffMockStrapping.git'
lazy var mockServer = MockNetworkServer()
let stubRequest = NetworkStubRequest(url: "someUrlAsString", httpMethod: .GET)
GET
method is written above as an examle. We support all http methods, and you can use any of them. You can see them here.
ANY
is a default parameter and means that method doesn't matter for you.
let stubResponse = NetworkStubResponse.json(json)
We use SwiftyJSON, so json
from the example above is an instance of JSON
.
If you need to create a response with pdf, png etc, simply use data
case instead.
let stub = NetworkStub(request: stubRequest, response: stubResponse)
mockServer.setStub(stub)
let query = ["query1": "1", "query2": "2"]
let stubRequest = NetworkStubRequest(url: "someUrlAsString",
query: query,
httpMethod: .GET)
Also we provide excludedQuery
. If you don't want to see some parameters in your request, use this option.
let delayInSeconds: TimeInterval = 5
let stub = NetworkStub(request: stubRequest, response: stubResponse, delay: delayInSeconds)
If you want to know which requests were called, you can use history
.
Simply use functions from MockNetworkHistoryProtocol
- RomanGL, [email protected],
- volokhin, [email protected],
- niceta, [email protected]
- ra2ra, [email protected]
TinkoffMockStrapping is available under the Apache License 2.0. See the LICENSE file for more info.