Skip to content

Instantly share code, notes, and snippets.

@joemasilotti
Created July 7, 2015 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemasilotti/7166fc375bc7af68c93f to your computer and use it in GitHub Desktop.
Save joemasilotti/7166fc375bc7af68c93f to your computer and use it in GitHub Desktop.
Completion Blocks in Cedar
typedef void(^BackgroundCompletion)();
@interface Backgrounder : NSObject
- (void)executeInBackground:(BackgroundCompletion)completion;
@end
describe(@"when the backgrounder completes", ^{
__block Backgrounder *backgrounder;
__block BackgroundCompletion completion;
beforeEach(^{
backgrounder = nice_fake_for([Backgrounder class]);
completion = nil;
backgrounder stub_method(@selector(executeInBackground:))
.and_do_block(^(BackgroundCompletion localCompletion) {
completion = localCompletion;
});
// call this whenever you want
completion();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment