Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify a block to execute for response #66

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

joshhinman
Copy link

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);.

@humblehacker
Copy link

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

@calmez
Copy link

calmez commented Aug 14, 2014

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

@joshhinman
Copy link
Author

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

@AnthonyMDev
Copy link

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

Josh Hinman added 2 commits October 13, 2015 21:00
# Conflicts:
#	Nocilla.podspec
#	Nocilla.xcodeproj/project.pbxproj
#	Nocilla/DSL/LSStubRequestDSL.h
#	Nocilla/Hooks/NSURLRequest/LSHTTPStubURLProtocol.m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants