It's probably an understatement to say that this has been going on for a while now. Obviously there is no silver bullet but I believe that more than 80% of the cases would be covered by a simple solution along the lines suggested here:
chrispix wrote:(1) Extending OCMockRecorder to have a more generalized method of ignoring matching any argument besides the current mechanism that only works with objects (and has an interesting implementation for pointers...)
- (id)ignoresArgAtIndex:(NSUInteger)index; //(or maybe just restrict it to non-object 'values' only, which may look like 'ignoresValueArgAtIndex')
And then in the 'matchesInvocation' method, you could just check if that particular index had been registered as needing to be ignored, and if so, ignoring that particular argument. Seems pretty simple, and technically still fits the recorder mantra.
In the end I added an approach based on this idea, but even simpler. Rather than "turning off" individual arguments by their index, you can now tell OCMock to completely ignore all non-object args in a given invocation, like:
- Code: Select all
[[[mock expect] ignoringNonObjectArgs] someMethodWithIntArgument:0]
I am aware that it could be the case that one argument must be matched exactly while another argument doesn't matter and both of them are primitives/structs. In that case the suggestion above would be needed. If there's demand I may add that in addition at a later point.