0

I'm trying to stub a method which has got an block argument.

[[[myMock stub] andCall:@selector(performBlock:) onObject:self] performBlock:[OCMArg any]];

The block is of a simple type.

typedef void (^MyBlock)(void);

Upon execution I get the following error:

unexpected method invoked: performBlock:<__NSStackBlock__: 0xbffff418>
                  stubbed: performBlock:<OCMAnyConstraint: 0x1c1ff70>

It seems as a block argument is not compatible with [OCMArg any]. Any tipps how to stub this method then?

fabb
  • 11,660
  • 13
  • 67
  • 111
  • 1
    Stubbing definitely works with block arguments and `[OCMock any]`. Can you post a bit more of your test case? – Christopher Pickslay Aug 13 '12 at 16:52
  • Thanks for trying out. I thought I have catched the problem, but it must lie elsewhere then. I'll post more when I'm working on it next time. – fabb Aug 13 '12 at 19:38

1 Answers1

0

Ok, I have cropped too much from my example. I had a second parameter of type bool which is not compatible with [OCMArg any].

Even worse: You don't get a compiler warning for it unless you use BOOL instead...

fabb
  • 11,660
  • 13
  • 67
  • 111