@@ -796,11 +796,17 @@ - (void)testCopyingOperationWithFaiureBlock
796796
797797- (void )testThatCacheEntryIsFlaggedWhenMappingCompletes
798798{
799+ [[NSURLCache sharedURLCache ] removeAllCachedResponses ];
800+
799801 RKObjectMapping *userMapping = [RKObjectMapping mappingForClass: [RKTestComplexUser class ]];
800802 [userMapping addAttributeMappingsFromDictionary: @{ @" name" : @" email" }];
801803 RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping: userMapping method: RKRequestMethodAny pathPattern: nil keyPath: @" human" statusCodes: RKStatusCodeIndexSetForClass (RKStatusCodeClassSuccessful)];
802804
803805 NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString: @" /coredata/etag" relativeToURL: [RKTestFactory baseURL ]]];
806+
807+ // Make sure the shared cache doesn't contain any response from previous tests
808+ while ([[NSURLCache sharedURLCache ] cachedResponseForRequest: request]) { }
809+
804810 RKObjectRequestOperation *requestOperation = [[RKObjectRequestOperation alloc ] initWithRequest: request responseDescriptors: @[ responseDescriptor ]];
805811 [requestOperation start ];
806812 expect ([requestOperation isFinished ]).will .beTruthy ();
@@ -814,11 +820,15 @@ - (void)testThatCacheEntryIsFlaggedWhenMappingCompletes
814820- (void )testThatCacheEntryIsNotFlaggedWhenMappingFails
815821{
816822 [[NSURLCache sharedURLCache ] removeAllCachedResponses ];
817-
823+
818824 RKObjectMapping *userMapping = [RKObjectMapping mappingForClass: [RKTestComplexUser class ]];
819825 RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping: userMapping method: RKRequestMethodAny pathPattern: @" /mismatch" keyPath: nil statusCodes: RKStatusCodeIndexSetForClass (RKStatusCodeClassSuccessful)];
820826
821827 NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString: @" /coredata/etag" relativeToURL: [RKTestFactory baseURL ]]];
828+
829+ // Make sure the shared cache doesn't contain any response from previous tests
830+ while ([[NSURLCache sharedURLCache ] cachedResponseForRequest: request]) { }
831+
822832 RKObjectRequestOperation *requestOperation = [[RKObjectRequestOperation alloc ] initWithRequest: request responseDescriptors: @[ responseDescriptor ]];
823833 [requestOperation start ];
824834 expect ([requestOperation isFinished ]).will .beTruthy ();
0 commit comments