I've defined some helper blocks within the BEGIN_SPEC
END_SPEC
block in my spec file that I reuse quite often. E.g. asserting that a certain dialog shows up:
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'd like to reuse this block over several other spec files. Is that somehow possible like we normally do it with spec helpers and rspec in the Ruby world?
How do you manage you global spec helpers?