You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/MockingURLProtocol.swift
+8-2
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,21 @@ import Foundation
10
10
11
11
/// The protocol which can be used to send Mocked data back. Use the `Mocker` to register `Mock` data
12
12
publicfinalclassMockingURLProtocol:URLProtocol{
13
-
13
+
14
+
enumMockingURLProtocolError:Swift.Error{
15
+
case missingMockedData(url:String)
16
+
}
17
+
14
18
/// Returns Mocked data based on the mocks register in the `Mocker`. Will end up in an error when no Mock data is found for the request.
15
19
publicoverridefunc startLoading(){
16
20
guard
17
21
let mock =Mocker.mock(for: request),
18
22
let response =HTTPURLResponse(url: mock.url, statusCode: mock.statusCode, httpVersion:Mocker.httpVersion.rawValue, headerFields: mock.headers),
19
23
let data = mock.data(for: request)
20
24
else{
21
-
fatalError("No mocked data found for url \(String(describing: request.url?.absoluteString)) method \(String(describing: request.httpMethod)). Did you forget to use `register()`?")
25
+
print("\n\n 🚨 No mocked data found for url \(String(describing: request.url?.absoluteString)) method \(String(describing: request.httpMethod)). Did you forget to use `register()`? 🚨 \n\n")
warn("Public properties, methods, classes or structs should be documented. Make use of `///` or `/* */` so it will show up inside the docs. (public_docs)",file: file,line: index+1)
130
147
end
131
148
end
132
149
end
133
150
134
151
## Check wether our file is larger than 200 lines and doesn't include any Marks
135
-
iffilelines.count > 200andfoundMark == false
136
-
warn("Consider to place some `MARK:` lines for files over 200 lines big.")
0 commit comments