Sha256: 21072069f022f359c723af53d2faa6705e1ba4b49cee22053dd8e2b82b07a31d

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

#import "EXPMatchers+raiseWithReason.h"
#import "EXPDefines.h"

EXPMatcherImplementationBegin(raiseWithReason, (NSString *expectedExceptionName, NSString *expectedReason)) {
    __block NSException *exceptionCaught = nil;
    
    match(^BOOL{
        BOOL expectedExceptionCaught = NO;
        @try {
            ((EXPBasicBlock)actual)();
        } @catch(NSException *e) {
            exceptionCaught = e;
            expectedExceptionCaught = (((expectedExceptionName == nil) || [[exceptionCaught name] isEqualToString:expectedExceptionName]) &&
                                       ((expectedReason == nil) || ([[exceptionCaught reason] isEqualToString:expectedReason])));
        }
        return expectedExceptionCaught;
    });
    
    failureMessageForTo(^NSString *{
        return [NSString stringWithFormat:@"expected: %@ (%@), got: %@ (%@)",
                expectedExceptionName ?: @"any exception",
                expectedReason ?: @"any reason",
                exceptionCaught ? [exceptionCaught name] : @"no exception",
                exceptionCaught ? [exceptionCaught reason] : @""];
    });
    
    failureMessageForNotTo(^NSString *{
        return [NSString stringWithFormat:@"expected: %@ (%@), got: %@ (%@)",
                expectedExceptionName ? [NSString stringWithFormat:@"not %@", expectedExceptionName] : @"no exception",
                expectedReason ? [NSString stringWithFormat:@"not '%@'", expectedReason] : @"no reason",
                exceptionCaught ? [exceptionCaught name] : @"no exception",
                exceptionCaught ? [exceptionCaught reason] : @"no reason"];
    });
}
EXPMatcherImplementationEnd

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
second_curtain-0.6.0 Demo/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m
second_curtain-0.5.0 Demo/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m
second_curtain-0.4.0 Demo/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m
second_curtain-0.3.0 Demo/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m
cocoapods-deintegrate-0.2.1 spec/fixtures/Project/StaticLibraries/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m
cocoapods-deintegrate-0.2.0 spec/fixtures/Project/StaticLibraries/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m
second_curtain-0.2.4 Demo/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m
second_curtain-0.2.3 Demo/Pods/Expecta/src/matchers/EXPMatchers+raiseWithReason.m