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: OHHTTPStubs/OHHTTPStubs.h
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -48,25 +48,25 @@ typedef id OHHTTPStubsRequestHandlerID;
48
48
#pragma mark - Class Methods
49
49
50
50
/*! Dedicated method to add a request handler
51
-
@param shouldReturnStubForRequest Block that should return YES if the request passed as parameter should be stubbed with the handler block, NO if it should hit the real world (or be managed by another request handler).
52
-
@param handler Block that will return the OHHTTPStubsResponse to use for stubbing, corresponding to the given request
51
+
@param testBlock Block that should return YES if the request passed as parameter should be stubbed with the handler block, NO if it should hit the real world (or be managed by another request handler).
52
+
@param responseHandler Block that will return the OHHTTPStubsResponse to use for stubbing, corresponding to the given request
53
53
@return an opaque object that uniquely identifies the handler and can be later used to remove it with removeRequestHandler:
@@ -54,7 +54,7 @@ This code will only stub requests ending with ".json", and in such case return t
54
54
For every request sent, whatever the framework used (`NSURLConnection`,
55
55
[`AFNetworking`](https://github.com/AFNetworking/AFNetworking/), or anything else):
56
56
57
-
* The block passed as first argument of `shouldStubRequestsPassingTest:withStubResponse:` will be called to check if we need to stub this request.
57
+
* The block passed as first argument of `stubRequestsPassingTest:withStubResponse:` will be called to check if we need to stub this request.
58
58
* If this block returned YES, the block passed as second argument will be called to let you return an `OHHTTPStubsResponse` object, describing the fake response to return.
59
59
60
60
_(In practice, it uses the URL Loading System of Cocoa and a custom `NSURLProtocol` to intercept the requests and stub them)_
@@ -114,7 +114,7 @@ Of course, and that's the main reason this is implemented with blocks, you can d
return [basename.pathExtension isEqualToString:@"json"]; // Only stub requests to *.json files
@@ -142,18 +142,18 @@ The `OHHTTPStubsResponse` header defines some constants for standard download sp
142
142
143
143
### Stack multiple request handlers
144
144
145
-
You can call `shouldStubRequestsPassingTest:withStubResponse:` multiple times.
145
+
You can call `stubRequestsPassingTest:withStubResponse:` multiple times.
146
146
It will just add the response handlers in an internal list of handlers.
147
147
148
148
When a network request is performed by the system, the response handlers are called in the reverse order that they have been added, the last added handler having priority over the first added ones.
149
-
The first handler that returns YES for the first parameter of `shouldStubRequestsPassingTest:withStubResponse:` is then used to reply to the request.
149
+
The first handler that returns YES for the first parameter of `stubRequestsPassingTest:withStubResponse:` is then used to reply to the request.
150
150
151
151
_This may be useful to install different stubs in different classes (say different UIViewControllers) and various places in your application, or to separate different stubs and stubbing conditions (like some stubs for images and other stubs for JSON files) more easily. See the `OHHTTPStubsDemo` project for a typical example._
152
152
153
153
You can remove the latest added handler with the `removeLastRequestHandler` method, and all handlers with the `removeAllRequestHandlers` method.
154
154
155
155
You can also remove any given handler with the `removeRequestHandler:` method.
156
-
This method takes as a parameter the object returned by `shouldStubRequestsPassingTest:withStubResponse:`.
156
+
This method takes as a parameter the object returned by `stubRequestsPassingTest:withStubResponse:`.
157
157
_Note that this returned object is already retained by `OHHTTPStubs` while the stub is installed, so you may keep it in a `__weak` variable (no need to keep a `__strong` reference)._
158
158
159
159
@@ -166,7 +166,7 @@ For a complete Xcode projet, see the `OHHTTPStubsDemo.xcworkspace` project in th
0 commit comments