Skip to content

Commit

Permalink
Add tests verifying expected behavior for availability of RKRequest r…
Browse files Browse the repository at this point in the history
…esponse property. closes #527
  • Loading branch information
blakewatters committed May 19, 2012
1 parent e681b85 commit 30f1198
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Tests/Logic/Network/RKRequestTest.m
Expand Up @@ -974,4 +974,28 @@ - (void)testThatIsLoadedIsYesDuringDidFailWithErrorCallback {
[loader waitForResponse]; [loader waitForResponse];
} }


- (void)testUnavailabilityOfResponseInDidFailWithErrorCallback {
NSURL *URL = [[NSURL alloc] initWithString:@"http://localhost:8765"];
RKTestResponseLoader* loader = [RKTestResponseLoader responseLoader];

RKClient *client = [RKClient clientWithBaseURL:URL];
RKRequest *request = [client requestWithResourcePath:@"/invalid"];
request.method = RKRequestMethodGET;
request.delegate = loader;
[request sendAsynchronously];
[loader waitForResponse];
assertThat(request.response, is(nilValue()));
}

- (void)testAvailabilityOfResponseWhenFailedDueTo500Response {
RKURL *URL = [[RKTestFactory baseURL] URLByAppendingResourcePath:@"/fail"];
RKRequest *request = [RKRequest requestWithURL:URL];
RKTestResponseLoader *responseLoader = [RKTestResponseLoader responseLoader];
request.delegate = responseLoader;
[request sendAsynchronously];
[responseLoader waitForResponse];
assertThat(request.response, is(notNilValue()));
assertThatInteger(request.response.statusCode, is(equalToInteger(500)));
}

@end @end

0 comments on commit 30f1198

Please sign in to comment.