Permalink
Browse files

Add tests verifying expected behavior for availability of RKRequest r…

…esponse property. closes #527
  • Loading branch information...
1 parent e681b85 commit 30f1198bb8ddf378cb1d959672fd477ea7cb8d0c @blakewatters blakewatters committed May 19, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 Tests/Logic/Network/RKRequestTest.m
@@ -974,4 +974,28 @@ - (void)testThatIsLoadedIsYesDuringDidFailWithErrorCallback {
[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

0 comments on commit 30f1198

Please sign in to comment.