I defined some auxiliary blocks in a block BEGIN_SPEC END_SPECin my spec file, which I often use. For instance. claiming a specific dialog box appears:
void (^expectOkAlert) (NSString *, NSString *) = ^void(NSString *expectedTitle, NSString *expectedMessage) {
UIAlertView *alertView = [UIAlertView mock];
[UIAlertView stub:@selector(alloc) andReturn:alertView];
[[alertView should] receive:@selector(initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:)
andReturn:alertView
withArguments:expectedTitle,expectedMessage,any(),@"OK",any()];
[[alertView should] receive:@selector(show)];
};
I would like to reuse this block for several other specification files. Is it somehow possible, as we usually do with spec helpers and rspec in the Ruby world?
How do you manage global spec assistants?
source
share