Skip to content

Commit

Permalink
Merge pull request kiwi-bdd#171 from eraserhd/improved_have_value_mes…
Browse files Browse the repository at this point in the history
…sages

Improved haveValue:forKey: messages
  • Loading branch information
allending committed Nov 23, 2012
2 parents d3ca11d + 18cf4ab commit 27d1c4a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Kiwi/KWHaveValueMatcher.m
Expand Up @@ -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;

Expand Down

0 comments on commit 27d1c4a

Please sign in to comment.