KWRespondToSelectorMatcher.m 1.0 KB

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