I need help with the following: I'm writing some BDD tests for an client API with the following structure:
@protocol MyAPIClientDelegate <NSObject>
-(void)myCallbackMethod:(id)response;
@end
// BEGIN: MyAPIClientSpec.h
SPEC_BEGIN(MyAPIClientSpec)
describe(@"MyAPIClientAPI ", ^{
__block MyAPI *api = nil;
__block id delegateMock = nil;
beforeEach(^{
delegateMock = [KWMock mockForProtocol:@protocol(MyAPIClientDelegate)];
api = [MyAPI APIClientWithDelegate:delegateMock];
});
afterEach(^{
delegateMock = nil;
api = nil;
});
it(@"should return a JSON { result: 'ok', token: <SOME_TOKEN> }", ^{
[[api should] receive:@selector(myMethodCall:)];
[[[delegateMock shouldEventually] receive] myCallbackMethod:any()];
[api myMethodCall];
});
});
SPEC_END
As you can see in the code above, I'm using any() to check that at least there is a parameter sent to the delegate.
Is there anyway to define a function (or objective-c block) to check the parameter?
Thanks!