ios - Examining a method argument on a mock object with Kiwi -


i need following: i'm writing bdd tests client api 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 json { result: 'ok', token: <some_token> }", ^{         [[api should] receive:@selector(mymethodcall:)];          [[[delegatemock shouldeventually] receive] mycallbackmethod:any()];          [api mymethodcall];     }); });  spec_end 

as can see in code above, i'm using any() check @ least there parameter sent delegate.

is there anyway define function (or objective-c block) check parameter?

thanks!

try using capture spy:

it(@"should return json { result: 'ok', token: <some_token> }", ^{     [[api should] receive:@selector(mymethodcall:)];      kwcapturespy *spy = [delegatemock captureargument:@selector(mycallbackmethod:) atindex:0];      [api mymethodcall];      [[spy.argument should] equal:/* ... */]; }); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -