Nocilla icon indicating copy to clipboard operation
Nocilla copied to clipboard

Add ability to specify a block to execute for response

Open joshhinman opened this issue 11 years ago • 4 comments

Example:

stubRequest(@"GET", @"http://www.example.com/").andDo(^(NSDictionary * __autoreleasing *headers, NSInteger *status, id<LSHTTPBody> __autoreleasing *body) {
    *status = 200;
    *body = @"Response!";
});

The block passed to andDo will not be executed until the request is made. This is useful for varying the response based on object state that changes by the time the request is made, and assertions can be made inside the block to check the state of the object between the "start loading" and "finish loading" states, e.g. XCTAssertTrue(myObj.isLoading);.

joshhinman avatar Mar 17 '14 22:03 joshhinman

I second this request. It would provide a workaround for issue #4 (expectations).

humblehacker avatar May 18 '14 21:05 humblehacker

Great. This is really something that is useful! This also enables that you can check on whether the URL got requested or not.

calmez avatar Aug 14 '14 15:08 calmez

@calmez I believe I've fixed the Cocoapod issue--try it now.

joshhinman avatar Oct 04 '14 01:10 joshhinman

Any chance we can get this working? I'd really like this feature!

AnthonyMDev avatar Aug 20 '15 19:08 AnthonyMDev