Sha256: 1beac0a3c2fd1a9c642fdaa349ab80ad014f67ccf56a70b33da9bb03b25fec90

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

#import "EXPMatchers+conformTo.h"
#import "NSValue+Expecta.h"
#import <objc/runtime.h>

EXPMatcherImplementationBegin(conformTo, (Protocol *expected)) {
    BOOL actualIsNil = (actual == nil);
    BOOL expectedIsNil = (expected == nil);

    prerequisite(^BOOL{
        return !(actualIsNil || expectedIsNil);
    });

    match(^BOOL{
        return [actual conformsToProtocol:expected];
    });

    failureMessageForTo(^NSString *{
        if(actualIsNil) return @"the object is nil/null";
        if(expectedIsNil) return @"the protocol is nil/null";

        NSString *name = NSStringFromProtocol(expected);
        return [NSString stringWithFormat:@"expected: %@ to conform to %@", actual, name];
    });

    failureMessageForNotTo(^NSString *{
        if(actualIsNil) return @"the object is nil/null";
        if(expectedIsNil) return @"the protocol is nil/null";

        NSString *name = NSStringFromProtocol(expected);
        return [NSString stringWithFormat:@"expected: %@ not to conform to %@", actual, name];
    });
}
EXPMatcherImplementationEnd

Version data entries

8 entries across 8 versions & 2 rubygems

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