Try this:
[[(NSObject*)mockDownloader shouldEventually] receive:@selector(downloadPOIsNear:completionBlock:)];
You can also use shouldEventuallyBeforeTimingOutAfter(seconds)
if needed.
Question
I have a simple manager object, and using mocks in kiwi, I want to check that when I call [aPOIManager fetchNear:location]
it calls downloadPOIsNear:completionBlock:
on its downloader.
Everything worked fine until I decided to dispatch the call to the downloader inside a grand central dispatch.
The call being asynchronous, the test now fails. Kiwi has a feature to check asynchronously some value, but not to check for asynchronous calls .
Here is part of my test :
it(@"should call the proximity downloader", ^{
CLLocation *location = [[CLLocation alloc] initWithLatitude:1.0f longitude:1.0f];
id<RMProximityDownloader> mockDownloader =
[KWMock mockForProtocol:@protocol(RMProximityDownloader)];
[[(NSObject*)mockDownloader should] receive:@selector(downloadPOIsNear:completionBlock:)];
RMPOIManager *aPOIManager = [[RMPOIManager alloc] initWithDownloader:mockDownloader];
[aPOIManager fetchNear:location];
});
Solution
Try this:
[[(NSObject*)mockDownloader shouldEventually] receive:@selector(downloadPOIsNear:completionBlock:)];
You can also use shouldEventuallyBeforeTimingOutAfter(seconds)
if needed.