allending/Kiwi — pull request #280 by jonklein (2013-05-21 15:30:03+00:00)
Title: implement an async watcher that always waits until the end before checking the result

This fixes #237 by introducing shouldAfterWait, shouldNotAfterWait, shouldAfterWaitOf(timeout) and shouldNotAfterWaitOf(timeout).

The existing helpers will complete immediately when the matcher evaluates to true, so it's not possible to verify that a value should stay the same during an async test.

The following tests illustrate a test unexpectedly passing with shouldEventually, and then failing as expected with shouldAfterWait:

```
__block NSString	*var = @"xyz";

it(@"should fail to detect changing value with shouldEventually", ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
var = @"xxx";
});

// This succeeds (unexpectedly?)
[[expectFutureValue(var) shouldEventually] equal: @"xyz"];
});

it(@"should detect changing value with shouldAfterWait", ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
var = @"xxx";
});

// This should fail as expected!
[[expectFutureValue(var) shouldAfterWait] equal: @"xyz"];
});

```