KWConformToProtocolMatcher.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // Licensed under the terms in License.txt
  3. //
  4. // Copyright 2010 Allen Ding. All rights reserved.
  5. //
  6. #import "KWConformToProtocolMatcher.h"
  7. #import "KWFormatter.h"
  8. @interface KWConformToProtocolMatcher()
  9. @property (nonatomic, assign) Protocol *protocol;
  10. @end
  11. @implementation KWConformToProtocolMatcher
  12. #pragma mark - Getting Matcher Strings
  13. + (NSArray *)matcherStrings {
  14. return @[@"conformToProtocol:"];
  15. }
  16. #pragma mark - Matching
  17. - (BOOL)evaluate {
  18. return [self.subject conformsToProtocol:self.protocol];
  19. }
  20. #pragma mark - Getting Failure Messages
  21. - (NSString *)failureMessageForShould {
  22. return [NSString stringWithFormat:@"expected subject to conform to %@ protocol",
  23. NSStringFromProtocol(self.protocol)];
  24. }
  25. - (NSString *)description {
  26. return [NSString stringWithFormat:@"conform to %@ protocol", NSStringFromProtocol(self.protocol)];
  27. }
  28. #pragma mark - Configuring Matchers
  29. - (void)conformToProtocol:(Protocol *)aProtocol {
  30. self.protocol = aProtocol;
  31. }
  32. @end