PMHTTP
PMHTTP copied to clipboard
Mock manager should have an .interceptAllUnhandledURLs() method
Right now the mock manager has 2 properties to control whether it intercepts unmocked requests, one for requests within the environment and one for requests outside (the idea being that we can intercept all requests to the API server but allow requests to external services, or vice versa).
A very common setup is to intercept all requests, so we should make it easier by having a method .interceptAllUnhandledURLs()
that sets both properties.
Alternatively we could refactor this into something like
var interceptedUnhandledURLs: UnhandledURLIntercept = []
struct UnhandledURLIntercept: OptionSet {
var rawValue: Int
static let environmental = UnhandledURLIntercept(rawValue: 1 << 0)
static let external = UnhandledURLIntercept(rawValue: 1 << 1)
static let all: UnhandledURLIntercept = [.environmental, .external]
}
var interceptUnhandledEnvironmentURLs: Bool {
get { return interceptedUnhandledURLs.contains(.environmental) }
set { newValue ? interceptedUnhandledURLs.insert(.environmental) : interceptedUnhandledURLs.remove(.environmental) }
}
var interceptUnhandledExternalURLs: Bool {
…
}
With redesigned environments (see #48) it's also not clear if we should support intercepting unhandled URLs per-environment, or just keep a global "all environments" toggle.