Created
July 7, 2015 16:16
-
-
Save joemasilotti/7166fc375bc7af68c93f to your computer and use it in GitHub Desktop.
Completion Blocks in Cedar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef void(^BackgroundCompletion)(); | |
@interface Backgrounder : NSObject | |
- (void)executeInBackground:(BackgroundCompletion)completion; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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