So I need to test whether a NSNotification
is posted. I tried the following code to spy on the argument.
[[NSNotificationCenter defaultCenter] stub:@selector(postNotification:)];
__block KWCaptureSpy *notificationSpy = [[NSNotificationCenter
defaultCenter] captureArgument:@selector(postNotification:) atIndex:0];
[[theValue(notificationSpy.argument.name) should] equal:theValue(SOME_NOTIFICATION)];
but the problem with this is the since it's asynchronous the argument is not always captured before testing. I can't add shouldEventually
for notificationSpy.argument.name either as it throws NSInternalConsistencyException
for accessing the argument before capturing.
I also tried,
[[SOME_NOTIFICATION should] bePosted];
and it failed as well.