Reputation: 3270
I'm looking to capture a block that is passed into a mock object. Here is the concrete function of class being mocked:
[self.imageFetcher fetchImageWithURL:url success:^(NSURL *successUrl, UIImage *image) {
//Implementation Details here
}];
Here is the my attempt to capturing the block:
OCMExpect([imageFetcher fetchImageWithURL:urlForSuccess success:[OCMArg checkWithBlock:^(void(^myBlock)(NSURL *,UIImage *)){
myBlock(urlForSuccess,[UIImage new]);
return YES;
}]]);
However, this doesn't seem to be working. How can I use the checkWithBlock
to capture the block and be able to call that block with parameters I choose?
Upvotes: 0
Views: 283
Reputation: 3014
If you want to invoke the block that is passed to the mock, then you should use [OCMArg invokeBlock]
. See section 2.6 in the documentation for details: http://ocmock.org/reference/#stubing-methods
Upvotes: 1