A new method allows to stub directly on instances of StubbornNetwork:
/// Stubs a given request.
///
/// When the client makes a request similar to the given `request`, data and response or error will be played back.
///
/// - Parameters:
/// - request: the request to be stubbed
/// - data: this data will be played back.
/// - response: this response will be played back.
/// - error: this error will be played back. If an error is given it inhibits any data and response from
/// being replayed.
public func stub(request: URLRequest,
data: Data? = nil,
response: URLResponse? = nil,
error: Error? = nil)
RequestMatcherOptions
RequestMatcherOptions are a way to control the matching behaviour of stubbed requests and client requests. If a clients requests only differ in the url, there is no need to fit the stubbed requests exactly to the requests the client will actually perform - body, headers and so on might be left out. This feature comes in handy when writing unit tests where the stubbing happens directly before the assertion as part of the test. Request matching defaults to .lenient, so if you need full control over differentiating requests, the .strict option set comes in handy, other than that there are the following options to choose from: .url, .httpMethod, .headers, .body.
A New Method
A new method allows to stub directly on instances of
StubbornNetwork
:RequestMatcherOptions
RequestMatcherOptions
are a way to control the matching behaviour of stubbed requests and client requests. If a clients requests only differ in the url, there is no need to fit the stubbed requests exactly to the requests the client will actually perform - body, headers and so on might be left out. This feature comes in handy when writing unit tests where the stubbing happens directly before the assertion as part of the test. Request matching defaults to.lenient
, so if you need full control over differentiating requests, the.strict
option set comes in handy, other than that there are the following options to choose from:.url
,.httpMethod
,.headers
,.body
.