Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 63 lines (50 sloc) 1.841 kb
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
//
// KWUserDefinedMatcher.h
// Kiwi
//
// Created by Luke Redpath on 16/06/2011.
// Copyright 2011 Allen Ding. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "KWMatcher.h"

typedef BOOL (^KWUserDefinedMatcherBlock)();

@interface KWUserDefinedMatcher : KWMatcher
{
    KWUserDefinedMatcherBlock matcherBlock;
    SEL selector;
    NSInvocation *invocation;
    NSString *failureMessageForShould;
    NSString *failureMessageForShouldNot;
}
@property (nonatomic, assign) SEL selector;
@property (nonatomic, copy) NSString *failureMessageForShould;
@property (nonatomic, copy) NSString *failureMessageForShouldNot;
@property (nonatomic, assign) KWUserDefinedMatcherBlock matcherBlock;
@property (nonatomic, copy) NSString *description;

+ (id)matcherWithSubject:(id)aSubject block:(KWUserDefinedMatcherBlock)aBlock;
- (id)initWithSubject:(id)aSubject block:(KWUserDefinedMatcherBlock)aBlock;
- (void)setSubject:(id)aSubject;
@end

#pragma mark -

typedef NSString * (^KWUserDefinedMatcherMessageBlock)(id);

@interface KWUserDefinedMatcherBuilder : NSObject
{
    KWUserDefinedMatcher *matcher;
    KWUserDefinedMatcherMessageBlock failureMessageForShouldBlock;
    KWUserDefinedMatcherMessageBlock failureMessageForShouldNotBlock;
    NSString *description;
}
@property (nonatomic, readonly) NSString *key;

+ (id)builder;
+ (id)builderForSelector:(SEL)aSelector;
- (id)initWithSelector:(SEL)aSelector;

#pragma mark -
#pragma mark Configuring The Matcher

- (void)match:(KWUserDefinedMatcherBlock)block;
- (void)failureMessageForShould:(KWUserDefinedMatcherMessageBlock)block;
- (void)failureMessageForShouldNot:(KWUserDefinedMatcherMessageBlock)block;
- (void)description:(NSString *)description;

#pragma mark -
#pragma mark Buiding The Matcher

- (KWUserDefinedMatcher *)buildMatcherWithSubject:(id)subject;
@end
Something went wrong with that request. Please try again.