Skip to content

Commit

Permalink
Make sure registerMatchers() works if defined after a spec. (Closes k…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeredpath committed Jan 23, 2012
1 parent 98e9b92 commit 28fc8f8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
33 changes: 33 additions & 0 deletions Examples/SimpleSpec.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,8 +6,41 @@


#import "Kiwi.h" #import "Kiwi.h"


@interface ABCDummyMatcher : KWMatcher
- (void)justWork;
@end

@implementation ABCDummyMatcher

+ (NSArray *)matcherStrings {
return [NSArray arrayWithObject:@"justWork"];
}

- (void)justWork {};

- (BOOL)evaluate
{
return YES;
}

@end

SPEC_BEGIN(SimpleSpec) SPEC_BEGIN(SimpleSpec)


describe(@"anything", ^{

it(@"allows matchers to be registered after the first spec", ^{
[[@"this" should] equal:@"this"];
});

registerMatchers(@"ABC");

it(@"can work with a custom registered matcher", ^{
[[@"anything" should] justWork];
});

});

describe(@"stack", ^{ describe(@"stack", ^{
__block NSMutableArray *arr = nil; __block NSMutableArray *arr = nil;


Expand Down
4 changes: 2 additions & 2 deletions Kiwi.xcodeproj/project.pbxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
Expand All @@ -1365,7 +1365,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
Expand Down
3 changes: 2 additions & 1 deletion Kiwi/KWContextNode.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ - (void)performExample:(KWExample *)example withBlock:(void (^)(void))exampleBlo


void (^outerExampleBlock)(void) = ^{ void (^outerExampleBlock)(void) = ^{
@try { @try {
[self.registerMatchersNode acceptExampleNodeVisitor:example];

if (performedExampleCount == 0) { if (performedExampleCount == 0) {
[self.registerMatchersNode acceptExampleNodeVisitor:example];
[self.beforeAllNode acceptExampleNodeVisitor:example]; [self.beforeAllNode acceptExampleNodeVisitor:example];
} }


Expand Down
2 changes: 1 addition & 1 deletion Kiwi/KWExample.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ - (void)visitItNode:(KWItNode *)aNode {
- (void)visitPendingNode:(KWPendingNode *)aNode { - (void)visitPendingNode:(KWPendingNode *)aNode {
if (aNode != exampleNode) if (aNode != exampleNode)
return; return;

[self reportResultForExampleNodeWithLabel:@"PENDING"]; [self reportResultForExampleNodeWithLabel:@"PENDING"];
} }


Expand Down

0 comments on commit 28fc8f8

Please sign in to comment.