Permalink
Browse files

Add test to make sure that only one timeoutTimer is created.

  • Loading branch information...
1 parent fa44916 commit e9bf8a2c92b69c8e60f9018b7dcd643463bbea02 @bmorton bmorton committed with blakewatters Jan 22, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 Specs/Network/RKRequestSpec.m
@@ -31,6 +31,7 @@ - (void)shouldDispatchRequest;
@end
@interface RKRequestSpec : RKSpec {
+ int _methodInvocationCounter;
}
@end
@@ -40,6 +41,11 @@ @implementation RKRequestSpec
- (void)setUp {
// Clear the cache directory
RKSpecClearCacheDirectory();
+ _methodInvocationCounter = 0;
+}
+
+- (int)incrementMethodInvocationCounter {
+ return _methodInvocationCounter++;
}
/**
@@ -101,6 +107,20 @@ - (void)testShouldTimeoutAtInterval {
[request release];
}
+- (void)testShouldCreateOneTimeoutTimer {
+ RKSpecResponseLoader* loader = [RKSpecResponseLoader responseLoader];
+ NSString* url = RKSpecGetBaseURL();
+ NSURL* URL = [NSURL URLWithString:url];
+ RKRequest* request = [[RKRequest alloc] initWithURL:URL];
+ request.delegate = loader;
+ id requestMock = [OCMockObject partialMockForObject:request];
+ [[[requestMock expect] andCall:@selector(incrementMethodInvocationCounter) onObject:self] createTimeoutTimer];
+ [requestMock sendAsynchronously];
+ [loader waitForResponse];
+ assertThatInt(_methodInvocationCounter, equalToInt(1));
+ [request release];
+}
+
#pragma mark - Background Policies
#if TARGET_OS_IPHONE

0 comments on commit e9bf8a2

Please sign in to comment.