Permalink
Browse files

Added a BeNil matcher that can be used with shouldEventually.

  • Loading branch information...
1 parent db5785e commit fa4570c6645feb199f634b8c896c43f63f0ed490 Luke Redpath committed Jan 14, 2011
Showing with 60 additions and 0 deletions.
  1. +16 −0 Kiwi/KWBeNilMatcher.h
  2. +43 −0 Kiwi/KWBeNilMatcher.m
  3. +1 −0 Kiwi/Kiwi.h
View
@@ -0,0 +1,16 @@
+//
+// KWBeNilMatcher.h
+// iOSFalconCore
+//
+// Created by Luke Redpath on 14/01/2011.
+// Copyright 2011 LJR Software Limited. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "KWMatcher.h"
+
+@interface KWBeNilMatcher : KWMatcher {
+
+}
+- (void)beNil;
+@end
View
@@ -0,0 +1,43 @@
+//
+// KWBeNilMatcher.m
+// iOSFalconCore
+//
+// Created by Luke Redpath on 14/01/2011.
+// Copyright 2011 LJR Software Limited. All rights reserved.
+//
+
+#import "KWBeNilMatcher.h"
+#import "KWFormatter.h"
+
+@implementation KWBeNilMatcher
+
+#pragma mark -
+#pragma mark Getting Matcher Strings
+
++ (NSArray *)matcherStrings {
+ return [NSArray arrayWithObjects:@"beNil", nil];
+}
+
+#pragma mark -
+#pragma mark Matching
+
+- (BOOL)evaluate {
+ return (BOOL)(self.subject == nil);
+}
+
+#pragma mark -
+#pragma mark Getting Failure Messages
+
+- (NSString *)failureMessageForShould {
+ return [NSString stringWithFormat:@"expected subject to be nil, got %@",
+ [KWFormatter formatObject:self.subject]];
+}
+
+- (NSString *)failureMessageForShouldNot {
+ return [NSString stringWithFormat:@"expected %@ not to be nil",
+ [KWFormatter formatObject:self.subject]];
+}
+
+- (void)beNil {}
+
+@end
View
@@ -17,6 +17,7 @@
#import "KWBeKindOfClassMatcher.h"
#import "KWBeMemberOfClassMatcher.h"
#import "KWBeTrueMatcher.h"
+#import "KWBeNilMatcher.h"
#import "KWBeWithinMatcher.h"
#import "KWBeZeroMatcher.h"
#import "KWBeforeAllNode.h"

0 comments on commit fa4570c

Please sign in to comment.