Skip to content

Commit d05e065

Browse files
committed
Add basic descriptions for invocation actions.
Helps in debugging and error reporting.
1 parent c81c481 commit d05e065

6 files changed

+28
-0
lines changed

Source/OCMock/OCMBlockCaller.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
4343
}
4444
}
4545

46+
- (NSString *)description
47+
{
48+
return [NSString stringWithFormat:@"[%@ - %p]: Calls `%@`", [self class], self, block];
49+
}
50+
4651
@end

Source/OCMock/OCMExceptionReturnValueProvider.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
2727
[[NSException exceptionWithName:OCMStubbedException reason:@"Exception stubbed in test." userInfo:@{ @"exception": returnValue }] raise];
2828
}
2929

30+
- (NSString *)description
31+
{
32+
return [NSString stringWithFormat:@"[%@ - %p]: Throws `%@`", [self class], self, returnValue];
33+
}
34+
3035
@end

Source/OCMock/OCMIndirectReturnValueProvider.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
4949
[anInvocation setSelector:originalSelector];
5050
}
5151

52+
- (NSString *)description
53+
{
54+
return [NSString stringWithFormat:@"[%@ - %p]: Calls `%@` on `%@`", [self class], self, NSStringFromSelector(selector), provider];
55+
}
56+
5257
@end

Source/OCMock/OCMNonRetainingObjectReturnValueProvider.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,10 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
3636
}
3737
[anInvocation setReturnValue:&returnValue];
3838
}
39+
40+
- (NSString *)description
41+
{
42+
return [NSString stringWithFormat:@"[%@ - %p]: Returns `%@`", [self class], self, returnValue];
43+
}
3944
@end
4045

Source/OCMock/OCMNotificationPoster.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
4040
[[NSNotificationCenter defaultCenter] postNotification:notification];
4141
}
4242

43+
- (NSString *)description
44+
{
45+
return [NSString stringWithFormat:@"[%@ - %p]: Posts `%@`", [self class], self, notification];
46+
}
4347

4448
@end

Source/OCMock/OCMRealObjectForwarder.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,9 @@ - (void)handleInvocation:(NSInvocation *)anInvocation
6060
}
6161
}
6262

63+
- (NSString *)description
64+
{
65+
return [NSString stringWithFormat:@"[%@ - %p]", [self class], self];
66+
}
6367

6468
@end

0 commit comments

Comments
 (0)