Closed abbeycode closed 4 years ago
Apologies. This is a known problem; see https://github.com/erikdoe/ocmock/issues/339#issuecomment-392204720. However, I obviously forgot to add this to limitations section in the documentation. I'll leave this issue open until I have time to document this limitation.
That's interesting, but you stated:
you cannot stub/mock class methods on
NSObject
for subclasses ofNSManagedObject
Does the limitation apply equally to custom methods defined on the NSManagedObject
subclass, as is the case for me?
The way I phrased this in the comment is a bit odd. The code is much clearer. Here's the commit with the change (line 90-93): https://github.com/erikdoe/ocmock/commit/c06779c5876740874eac64e301da3ba00523f894?diff=unified
I've been tearing my hair out trying to figure out why one of my class stubs that worked on OCMock v2.x isn't working now with v3.6. This is the class method signature:
I'm stubbing it like so:
The assertion fails, because it's calling through to the class's implementation. If I invoke the method on
classMock
instead ofMyClass
, I get this:There's another more complicated class method exhibiting the same behavior.
I'm completely stuck. I've tried tinkering with the OCMArg matchers, tried using the
ClassMethod
macro, and other more subtle tweaks, but I'm out of ideas. What am I missing? Does it matter that MyClass is a Core Data class, deriving from NSManagedObject?