Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #171 from eraserhd/improved_have_value_messages

Improved haveValue:forKey: messages
  • Loading branch information...
commit 27d1c4ae14769ed35eb40cd488b4cb06281dd2f6 2 parents d3ca11d + 18cf4ab
Allen Ding authored
Showing with 14 additions and 3 deletions.
  1. +14 −3 Kiwi/KWHaveValueMatcher.m
17 Kiwi/KWHaveValueMatcher.m
View
@@ -70,12 +70,23 @@ - (BOOL)evaluate {
- (NSString *)failureMessageForShould {
if (self.expectedValue == nil) {
- return [NSString stringWithFormat:@"expected subject to have a value for key %@", self.expectedKey];
+ return [NSString stringWithFormat:@"expected subject to have a value for key %@",
+ [KWFormatter formatObject:self.expectedKey]];
+ }
+ id subjectValue = [self subjectValue];
+ if (subjectValue) {
+ return [NSString stringWithFormat:@"expected subject to have value %@ for key %@, but it had value %@ instead",
+ [KWFormatter formatObject:self.expectedValue],
+ [KWFormatter formatObject:self.expectedKey],
+ [KWFormatter formatObject:subjectValue]];
+ } else {
+ return [NSString stringWithFormat:@"expected subject to have value %@ for key %@, but the key was not present",
+ [KWFormatter formatObject:self.expectedValue],
+ [KWFormatter formatObject:self.expectedKey]];
}
- return [NSString stringWithFormat:@"expected subject to have value %@ for key %@", self.expectedValue, self.expectedKey];
}
-- (id)subjectValue;
+- (id)subjectValue
{
id value = nil;
Please sign in to comment.
Something went wrong with that request. Please try again.