したがって、 aNSNotification
が投稿されているかどうかをテストする必要があります。引数をスパイするために次のコードを試しました。
[[NSNotificationCenter defaultCenter] stub:@selector(postNotification:)];
__block KWCaptureSpy *notificationSpy = [[NSNotificationCenter
defaultCenter] captureArgument:@selector(postNotification:) atIndex:0];
[[theValue(notificationSpy.argument.name) should] equal:theValue(SOME_NOTIFICATION)];
しかし、これの問題は、非同期であるため、テスト前に引数が常にキャプチャされるとは限らないことです。キャプチャする前に引数にアクセスするためshouldEventually
にスローされるため、notificationSpy.argument.nameにも追加できません。NSInternalConsistencyException
私も試しましたが、
[[SOME_NOTIFICATION should] bePosted];
これも失敗しました。