Skip to content

Commit

Permalink
Updated example.
Browse files Browse the repository at this point in the history
The comma in the stringWithFormat call was causing a conflict with the precisely specified macro, so change it to delegate to a function call with VA_ARGS and have the function call KWMatchers.
  • Loading branch information
Luke Redpath committed Jun 17, 2011
1 parent 8737c71 commit fab24c5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Examples/ExampleSpec.m
Expand Up @@ -71,6 +71,9 @@ - (void)haveFighters;
Cruiser *cruiser = subject;
return cruiser.fighters.count > 0;
}];
[builder failureMessageForShould:^(id subject) {
return [NSString stringWithFormat:@"%@ should have fighters", subject];
}];
});

it(@"should have fighters (using custom matcher)", ^{
Expand Down
2 changes: 2 additions & 0 deletions Kiwi/KWMatchers.h
Expand Up @@ -31,3 +31,5 @@ typedef void (^KWMatchersBuildingBlock)(KWUserDefinedMatcherBuilder *);

- (KWUserDefinedMatcher *)matcherForSelector:(SEL)selector subject:(id)subject;
@end

void KWDefineMatchers(NSString *selectorString, KWMatchersBuildingBlock block);
6 changes: 6 additions & 0 deletions Kiwi/KWMatchers.m
Expand Up @@ -64,3 +64,9 @@ - (KWUserDefinedMatcher *)matcherForSelector:(SEL)selector subject:(id)subject {


@end

void KWDefineMatchers(NSString *selectorString, KWMatchersBuildingBlock block)
{
[KWMatchers defineMatcher:selectorString as:block];
}

2 changes: 1 addition & 1 deletion Kiwi/KiwiMacros.h
Expand Up @@ -46,7 +46,7 @@
#define it(...) itWithCallSite(KW_THIS_CALLSITE, __VA_ARGS__)
#define pending(...) pendingWithCallSite(KW_THIS_CALLSITE, __VA_ARGS__)
#define xit(...) pendingWithCallSite(KW_THIS_CALLSITE, __VA_ARGS__)
#define defineMatcher(selectorString, block) [KWMatchers defineMatcher:selectorString as:block]
#define defineMatcher(...) KWDefineMatchers(__VA_ARGS__)
#endif // #if KW_BLOCKS_ENABLED

// If a gcc compatible compiler is available, use the statement and
Expand Down

0 comments on commit fab24c5

Please sign in to comment.