Skip to content

Instantly share code, notes, and snippets.

@ivan3bx
Created March 10, 2010 07:33
Show Gist options
  • Save ivan3bx/327641 to your computer and use it in GitHub Desktop.
Save ivan3bx/327641 to your computer and use it in GitHub Desktop.
Alternative to using OCMock for simple stubbing of NSHTTPURLResponse statusCode
/*
* Subclassing in this case wins over mocking
*/
@interface MockHTTPURLResponse : NSHTTPURLResponse {
NSInteger statusCode;
}
@property(readwrite,nonatomic) NSInteger statusCode;
@end
@implementation MockHTTPURLResponse
@synthesize statusCode;
+(MockHTTPURLResponse *)responseWithStatus:(int)code
{
MockHTTPURLResponse *result = [[MockHTTPURLResponse alloc] init];
[result setStatusCode:code];
return result;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment