Permalink
Browse files

A new macro, waitFor, acts like a shouldEventually but never fails. I…

…t can be used to fo

specs to wait for asynchronous operations to end (where you don't really care about the
in order to ensure that stray operations do not cause side effects on subsequent tests.
  • Loading branch information...
1 parent 637f34f commit bf985c489153999fa1d89f82b5e75615329743db Luke Redpath committed Jan 17, 2011
Showing with 7 additions and 1 deletion.
  1. +2 −0 Kiwi/KWAsyncVerifier.m
  2. +2 −1 Kiwi/KWExpectationType.h
  3. +3 −0 Kiwi/KiwiMacros.h
View
2 Kiwi/KWAsyncVerifier.m
@@ -43,6 +43,8 @@ - (void)verifyWithProbe:(KWAsyncMatcherProbe *)aProbe {
NSString *message = [aProbe.matcher failureMessageForShouldNot];
KWFailure *failure = [KWFailure failureWithCallSite:self.callSite message:message];
[self.reporter reportFailure:failure];
+ } else if (self.expectationType == KWExpectationTypeMaybe) {
+ // don't do anything
}
}
[poller release];
View
3 Kiwi/KWExpectationType.h
@@ -8,7 +8,8 @@
enum {
KWExpectationTypeShould,
- KWExpectationTypeShouldNot
+ KWExpectationTypeShouldNot,
+ KWExpectationTypeMaybe
};
typedef NSUInteger KWExpectationType;
View
3 Kiwi/KiwiMacros.h
@@ -25,6 +25,9 @@
#define shouldEventually attachToVerifier:KW_ADD_ASYNC_VERIFIER(KWExpectationTypeShould, kKW_DEFAULT_PROBE_TIMEOUT)
#define shouldEventuallyBeforeTimingOutAfter(timeout) attachToVerifier:KW_ADD_ASYNC_VERIFIER(KWExpectationTypeShould, timeout)
+// wait for is like a shouldEventually but will not fail if it's never satisfied
+#define waitFor attachToVerifier:KW_ADD_ASYNC_VERIFIER(KWExpectationTypeMaybe, kKW_DEFAULT_PROBE_TIMEOUT)
+
// used to wrap a pointer to an object that will change in the future (used with shouldEventually)
#define theObject(objectPtr) [KWFutureObject objectWithObjectPointer:objectPtr]
#define theReturnValueOfBlock(block) [KWFutureObject objectWithReturnValueOfBlock:block]

0 comments on commit bf985c4

Please sign in to comment.