Here's how you could make fun of sendAsynchronousRequest:
NSDictionary *serverResponse = @{ @"response" : [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:200 HTTPVersion:nil headerFields:@{}],
@"data" : [@"SOMEDATA" dataUsingEncoding:NSUTF8StringEncoding]
};
id connectionMock = [OCMockObject mockForClass:NSURLConnection.class];
[[[connectionMock expect] andDo:^(NSInvocation *invocation) {
void (^handler)(NSURLResponse*, NSData*, NSError*);
handler = [invocation getArgumentAtIndexAsObject:4];
handler(serverResponse[@"response"], serverResponse[@"data"], serverResponse[@"error"]);
}] sendAsynchronousRequest:OCMOCK_ANY queue:OCMOCK_ANY completionHandler:OCMOCK_ANY];
EDIT
, . [NSURLConnection sendAsynchronousRequest: queue: completionHandler:]. _cmd self, Objective-C. , NSInvocation, 4 . , , , .
getArgumentAtIndexAsObject , OCMock, . , NSInvocation+OCMAdditions.h. , id.