Skip to content

Instantly share code, notes, and snippets.

@zmcartor
Created March 5, 2013 00:39
Show Gist options
  • Save zmcartor/5087032 to your computer and use it in GitHub Desktop.
Save zmcartor/5087032 to your computer and use it in GitHub Desktop.
// beforeEach/afterEach are Kiwi constructs
beforeEach(^{
//register as Protocol delegate, the magic begins
[NSURLProtocol registerClass:[ILCannedURLProtocol class]];
// Default HTTP status code
[ILCannedURLProtocol setCannedStatusCode:200];
// Configure ILtesting only for certain verbs if you like
[ILCannedURLProtocol setSupportedMethods:[[NSArray alloc] initWithObjects:@"GET",@"POST", @"PUT", nil]];
// Default headers. Ill be returning JSON here.
NSMutableDictionary *headers = [[NSMutableDictionary alloc] init];
[headers setObject:@"application/json; charset=utf-8" forKey:@"Content-Type"];
[ILCannedURLProtocol setCannedHeaders: headers];
});
afterEach(^{
// We must unregister the class after each test.
[NSURLProtocol unregisterClass:[ILCannedURLProtocol class]];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment