Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a beSubclassOfClass matcher for matching Class ids

  • Loading branch information...
commit 373a0c07bbd3dc56aba3e84f1d1c25aa3cad3677 1 parent 9048616
@hartbit hartbit authored
View
8 Kiwi.xcodeproj/project.pbxproj
@@ -8,6 +8,8 @@
/* Begin PBXBuildFile section */
4B9D040814D3EE7300707E83 /* KWExampleGroupDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A3758CDA1418CDC10051268A /* KWExampleGroupDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 637FFB2A150513D500DBFE8F /* KWBeSubclassOfClassMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 637FFB28150513D500DBFE8F /* KWBeSubclassOfClassMatcher.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 637FFB2B150513D500DBFE8F /* KWBeSubclassOfClassMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 637FFB29150513D500DBFE8F /* KWBeSubclassOfClassMatcher.m */; };
9F4E04DC12DFB71F00A3440B /* KWFutureObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F4E04D712DFB71F00A3440B /* KWFutureObject.m */; };
9F4E04DF12DFB71F00A3440B /* KWProbePoller.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F4E04DA12DFB71F00A3440B /* KWProbePoller.m */; };
9FB1D28412DFB60400693E30 /* KWAsyncVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FB1D28312DFB60400693E30 /* KWAsyncVerifier.m */; };
@@ -247,6 +249,8 @@
28D7ACF70DDB3853001CB0EB /* KiwiViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KiwiViewController.m; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* Kiwi_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Kiwi_Prefix.pch; sourceTree = "<group>"; };
+ 637FFB28150513D500DBFE8F /* KWBeSubclassOfClassMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWBeSubclassOfClassMatcher.h; sourceTree = "<group>"; };
+ 637FFB29150513D500DBFE8F /* KWBeSubclassOfClassMatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWBeSubclassOfClassMatcher.m; sourceTree = "<group>"; };
9F324E9112DFB17200A871F1 /* Contributors.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Contributors.txt; sourceTree = "<group>"; };
9F4E04C812DFB6CB00A3440B /* KWAsyncVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWAsyncVerifier.h; sourceTree = "<group>"; };
9F4E04D612DFB71F00A3440B /* KWFutureObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWFutureObject.h; sourceTree = "<group>"; };
@@ -656,6 +660,8 @@
F54A4B3711733E8A002442C5 /* KWBeKindOfClassMatcher.m */,
F54A4BDE117347EF002442C5 /* KWBeMemberOfClassMatcher.h */,
F54A4BDF117347EF002442C5 /* KWBeMemberOfClassMatcher.m */,
+ 637FFB28150513D500DBFE8F /* KWBeSubclassOfClassMatcher.h */,
+ 637FFB29150513D500DBFE8F /* KWBeSubclassOfClassMatcher.m */,
F58F587E117DACF500D05908 /* KWBeTrueMatcher.h */,
F58F587F117DACF500D05908 /* KWBeTrueMatcher.m */,
F5A1E68011743C4A002223E1 /* KWBeWithinMatcher.h */,
@@ -935,6 +941,7 @@
A34FADB713BBF4B2003968B2 /* KWBeIdenticalToMatcher.h in Headers */,
A34FADB813BBF4B2003968B2 /* KWBeKindOfClassMatcher.h in Headers */,
A34FADB913BBF4B2003968B2 /* KWBeMemberOfClassMatcher.h in Headers */,
+ 637FFB2A150513D500DBFE8F /* KWBeSubclassOfClassMatcher.h in Headers */,
A34FADBA13BBF4B2003968B2 /* KWBeTrueMatcher.h in Headers */,
A34FADBB13BBF4B2003968B2 /* KWBeWithinMatcher.h in Headers */,
A34FADBC13BBF4B2003968B2 /* KWBeZeroMatcher.h in Headers */,
@@ -1173,6 +1180,7 @@
F5BD4F1F116D76EA00D813AF /* KWMatchVerifier.m in Sources */,
F54A4B3911733E8A002442C5 /* KWBeKindOfClassMatcher.m in Sources */,
F54A4BE1117347EF002442C5 /* KWBeMemberOfClassMatcher.m in Sources */,
+ 637FFB2B150513D500DBFE8F /* KWBeSubclassOfClassMatcher.m in Sources */,
F54A4C1711734B82002442C5 /* KWConformToProtocolMatcher.m in Sources */,
F54A4C49117364AC002442C5 /* KWValue.m in Sources */,
F5A1E68311743C4A002223E1 /* KWBeWithinMatcher.m in Sources */,
View
20 Kiwi/KWBeSubclassOfClassMatcher.h
@@ -0,0 +1,20 @@
+//
+// Licensed under the terms in License.txt
+//
+// Copyright 2010 Allen Ding. All rights reserved.
+//
+
+#import "KiwiConfiguration.h"
+#import "KWMatcher.h"
+
+@interface KWBeSubclassOfClassMatcher : KWMatcher {
+@private
+ Class targetClass;
+}
+
+#pragma mark -
+#pragma mark Configuring Matchers
+
+- (void)beSubclassOfClass:(Class)aClass;
+
+@end
View
61 Kiwi/KWBeSubclassOfClassMatcher.m
@@ -0,0 +1,61 @@
+//
+// Licensed under the terms in License.txt
+//
+// Copyright 2010 Allen Ding. All rights reserved.
+//
+
+#import "KWBeSubclassOfClassMatcher.h"
+#import "KWFormatter.h"
+
+@interface KWBeSubclassOfClassMatcher()
+
+#pragma mark -
+#pragma mark Properties
+
+@property (nonatomic, readwrite, assign) Class targetClass;
+
+@end
+
+@implementation KWBeSubclassOfClassMatcher
+
+#pragma mark -
+#pragma mark Properties
+
+@synthesize targetClass;
+
+#pragma mark -
+#pragma mark Getting Matcher Strings
+
++ (NSArray *)matcherStrings {
+ return [NSArray arrayWithObject:@"beSubclassOfClass:"];
+}
+
+#pragma mark -
+#pragma mark Matching
+
+- (BOOL)evaluate {
+ return [self.subject isSubclassOfClass:self.targetClass];
+}
+
+#pragma mark -
+#pragma mark Getting Failure Messages
+
+- (NSString *)failureMessageForShould {
+ return [NSString stringWithFormat:@"expected subject to be subclass of %@",
+ NSStringFromClass(self.targetClass)];
+}
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"be member of %@",
+ NSStringFromClass(self.targetClass)];
+}
+
+#pragma mark -
+#pragma mark Configuring Matchers
+
+- (void)beSubclassOfClass:(Class)aClass {
+ self.targetClass = aClass;
+}
+
+@end
View
1  Kiwi/Kiwi.h
@@ -20,6 +20,7 @@ extern "C" {
#import "KWBeIdenticalToMatcher.h"
#import "KWBeKindOfClassMatcher.h"
#import "KWBeMemberOfClassMatcher.h"
+#import "KWBeSubclassOfClassMatcher.h"
#import "KWBeTrueMatcher.h"
#import "KWBeNilMatcher.h"
#import "KWBeNonNilMatcher.h"
Please sign in to comment.
Something went wrong with that request. Please try again.