Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

66 lines (51 sloc) 2.465 kb
// Licensed under the terms in License.txt
// Copyright 2010 Allen Ding. All rights reserved.
#import "Kiwi.h"
#import "KiwiTestConfiguration.h"
#import "TestClasses.h"
@interface KWBlockRaiseMatcherTest : SenTestCase
@implementation KWBlockRaiseMatcherTest
- (void)testItShouldHaveTheRightMatcherStrings {
NSArray *matcherStrings = [KWBlockRaiseMatcher matcherStrings];
NSArray *expectedStrings = @[@"raise",
STAssertEqualObjects([matcherStrings sortedArrayUsingSelector:@selector(compare:)],
[expectedStrings sortedArrayUsingSelector:@selector(compare:)],
@"expected specific matcher strings");
- (void)testItShouldMatchForRaisingBlocks {
id cruiser = [Cruiser cruiser];
id subject = [KWBlock blockWithBlock:^{ [cruiser raise]; }];
id matcher = [KWBlockRaiseMatcher matcherWithSubject:subject];
[matcher raise];
STAssertTrue([matcher evaluate], @"expected positive match");
- (void)testItShouldNotMatchForNonRaisingBlocks {
id cruiser = [Cruiser cruiser];
id subject = [KWBlock blockWithBlock:^{ [cruiser raiseShields]; }];
id matcher = [KWBlockRaiseMatcher matcherWithSubject:subject];
[matcher raise];
STAssertFalse([matcher evaluate], @"expected negative match");
- (void)testItShouldHaveHumanReadableDescription
id matcher = [KWBlockRaiseMatcher matcherWithSubject:nil];
STAssertEqualObjects(@"raise nothing", [matcher description], @"description should match");
[matcher raise];
STAssertEqualObjects(@"raise exception", [matcher description], @"description should match");
[matcher raiseWithName:@"DummyException"];
STAssertEqualObjects(@"raise DummyException", [matcher description], @"description should match");
[matcher raiseWithReason:@"for testing purposes"];
STAssertEqualObjects(@"raise exception \"for testing purposes\"", [matcher description], @"description should match");
[matcher raiseWithName:@"DummyException" reason:@"for testing purposes"];
STAssertEqualObjects(@"raise DummyException \"for testing purposes\"", [matcher description], @"description should match");
#endif // #if KW_TESTS_ENABLED
Jump to Line
Something went wrong with that request. Please try again.