forked from kiwi-bdd/Kiwi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
KWBeSubclassOfClassMatcherTest.m
66 lines (53 loc) · 2.31 KB
/
KWBeSubclassOfClassMatcherTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Licensed under the terms in License.txt
//
// Copyright 2010 Allen Ding. All rights reserved.
//
#import "Kiwi.h"
#import "KiwiTestConfiguration.h"
#import "TestClasses.h"
#if KW_TESTS_ENABLED
@interface KWBeSubclassOfClassMatcherTest : SenTestCase
@end
@implementation KWBeSubclassOfClassMatcherTest
- (void)testItShouldHaveTheRightMatcherStrings {
NSArray *matcherStrings = [KWBeSubclassOfClassMatcher matcherStrings];
NSArray *expectedStrings = @[@"beSubclassOfClass:"];
STAssertEqualObjects([matcherStrings sortedArrayUsingSelector:@selector(compare:)],
[expectedStrings sortedArrayUsingSelector:@selector(compare:)],
@"expected specific matcher strings");
}
- (void)testItShouldMatchSubclassesOfAClass {
id subject = [Cruiser class];
id matcher = [KWBeSubclassOfClassMatcher matcherWithSubject:subject];
[matcher beSubclassOfClass:[Cruiser class]];
STAssertTrue([matcher evaluate], @"expected positive match");
}
- (void)testItShouldNotMatchNonSubclassesOfAClass {
id subject = [Cruiser class];
id matcher = [KWBeSubclassOfClassMatcher matcherWithSubject:subject];
[matcher beSubclassOfClass:[Fighter class]];
STAssertFalse([matcher evaluate], @"expected negative match");
}
- (void)testItShouldHaveHumanReadableDescription
{
id matcher = [KWBeSubclassOfClassMatcher matcherWithSubject:nil];
[matcher beSubclassOfClass:[Cruiser class]];
STAssertEqualObjects(@"be subclass of Cruiser", [matcher description], @"description should match");
}
- (void)testItShouldHaveInformativeFailureMessageForShould
{
id subject = [Cruiser cruiser];
id matcher = [KWBeSubclassOfClassMatcher matcherWithSubject:subject];
[matcher beSubclassOfClass:[Fighter class]];
STAssertEqualObjects([matcher failureMessageForShould], @"expected subject to be subclass of Fighter, got Cruiser", @"failure message should match");
}
- (void)testItShouldHaveInformativeFailureMessageForShouldNot
{
id subject = [Cruiser cruiser];
id matcher = [KWBeSubclassOfClassMatcher matcherWithSubject:subject];
[matcher beSubclassOfClass:[Fighter class]];
STAssertEqualObjects([matcher failureMessageForShouldNot], @"expected subject not to be subclass of Fighter, got Cruiser", @"failure message should match");
}
@end
#endif // #if KW_TESTS_ENABLED