-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix multiple calls in same recorder #485
base: master
Are you sure you want to change the base?
Conversation
if([self didRecordInvocation] && [self currentlyRecordingInMacro]) | ||
{ | ||
[NSException raise:NSInvalidArgumentException | ||
format:@"Recorder attempting to record `%s` but recorder has already recorded a stub for: `%@`. " | ||
@"Are there multiple invocations on mocks in a single macro?", | ||
sel_getName(aSelector), [self description]]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move this block into forwardInvocation:
? There's another assert there anyway, and I cannot see a benefit for detecting this case here.
{ | ||
returnValue = mockObject; | ||
} | ||
else if ([anInvocation methodIsInCreateFamily]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this needs to be in an else branch. Somehow I find the implementation confusing. First we set a "default" return value outside the if statement, then we overwrite it in the if statement, or, alternatively, we manipulate the original value in an else-if. I get why the inCreateFamily check is there, and it's a good additional fix to the change in the PR, but I think I'd restructure this when merging. (No action needed on your part.)
- (BOOL)currentlyRecordingInMacro | ||
{ | ||
return [[OCMMacroState globalState] recorder] == self; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move the check from methodSignatureForSelector:
to forwardInvocation:
then the code in this method is only needed once. I find the name confusing and can't think of a better name. In any case, I think any name wouldn't add much to explain what's happening and given this method is only needed once I'd inline it.
This is intended as a fix for #478