I need help with the following: I am writing several BDD tests for the 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 above code, I use any () to verify that at least there is a parameter sent to the delegate.
Is there a way to define a function (or an objective-c block) to check a parameter?
Thanks!
source share