kiwi-bdd / Kiwi

Simple BDD for iOS
BSD 3-Clause "New" or "Revised" License
4.14k stars 512 forks source link

KWCaptureSpy how it works? Or what i do wrong? #677

Closed bimawa closed 8 years ago

bimawa commented 8 years ago

Guys hi! Help pls can't understand how working KWCaptureSpy I try test Async call In this case all fine, where receiveOrderDetails must be async;

KWCaptureSpy *kwCaptureSpy = [screenPresenter captureArgument:@selector(receiveOrderDetails:) atIndex:0];
[screenPresenter receiveOrderDetails:[ZMOrderResponseModel new]];
[[expectFutureValue(kwCaptureSpy.argument) shouldEventuallyBeforeTimingOutAfter(10)] beNonNil];

But in next code throw a exception: 'Argument requested has yet to be captured.'

KWCaptureSpy *kwCaptureSpy = [screenPresenter captureArgument:@selector(receiveOrderDetails:) atIndex:0];
[[expectFutureValue(kwCaptureSpy.argument) shouldEventuallyBeforeTimingOutAfter(10)] beNonNil];
[screenPresenter receiveOrderDetails:[ZMOrderResponseModel new]];

And i feel not 10 sec of waiting. Its a bug or my break fingers? Version of Kiwi (cocoapods, 2.4)

sharplet commented 8 years ago

Instead of KWCaptureSpy, you should be able to use the receive: matcher. For example:

[[screenPresenter shouldEventually] receive:@selector(receiveOrderDetails:)];
// execute could under test
bimawa commented 8 years ago
                                                                                  OK worked thank you !