In the code I'm testing, I have an NSPredicate and I'm filtering an array:
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"status == %d || status == %d", FVFileReadyStatus, FVFileWaitingStatus];
[myArray filterUsingPredicate:predicate];
I have a method to return a mock, which will eventually get added to myArray
. FVFileStatus
is a typedef enum. Because I'm using a predicate, the predicate is calling valueForKey
, so I need to stub that out:
-(id)mockFVFileHandleWithStatus:(FVFileStatus)status {
id mock = [OCMockObject mockForClass:[FVFileHandle class]];
[[[mock stub] andReturnValue:OCMOCK_VALUE(status)] valueForKey:[OCMArg checkWithSelector:@selector(isEqualToString:) onObject:@"status"]];
return mock;
}
When I run my test, it fails on the filter. I get an NSInvalidArgumentException - Reason: Return value does not match method signature
.
I'm not sure how to setup the stub so it will work with an NSPredicate.
Can anybody help?