-
Notifications
You must be signed in to change notification settings - Fork 511
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
Confusion with nullMock and addObserver:... #371
Comments
I believe you've exposed a bug in Kiwi's implementation. Namely, the following test fails, although I believe it should succeed: it(@"asserts a null mock receives -addObserver:forKeyPath:options:context:", ^{
NSObject *nullMock = [NSObject nullMock];
[[nullMock should] receive:@selector(addObserver:forKeyPath:options:context:)];
[nullMock addObserver:[NSObject new]
forKeyPath:@"description"
options:0
context:nil];
}); I'll try looking into it. |
I've worked with Kiwi mocks for KVO in the past and they seemed fine, but the nullMock is I think ignoring more than it should do. Instance methods on NSObject should probably be allowed to pass through. |
The weird thing is that most instance methods do work. The following test passes, as expected: it(@"asserts a null mock receives -description", ^{
NSObject *nullMock = [NSObject nullMock];
[[nullMock should] receive:@selector(description)];
[nullMock description];
}); I believe the problem is specific to |
This issue comes up for me even with regular mock and not just nullMock. I realize this issue is old, sorry to disturb the peace :( |
It's been a few months since I've had a chance to do much with Kiwi, but now getting back into it, and can't seem to make sense of the following. Am I doing something drastically wrong?
I'm trying to write a test that validates that an object has an observer added to it. in my code, I'm trying to inject a nullMock into the class being tested so that I can check that the KVO calls are being made. I started with a real instance of the observed class and this was working ok, but the automatic stubbing was causing problems elsewhere, so I wanted to adapt the tests to use mocks to simplify things.
The code below is a example of this behaviour, not from my project, but the effect is the same.
When
observed
is a nullMock, theaddObserver
expectation fails, but theaddObject
is correctly ignored.When
observed
is a mock, the expectation passes, but then I get a failure because of the unexpectedaddObject
(which is correct behaviour for Kiwi).So the problem appears to be that Kiwi can't set an expectation on addObserver:forKeyPath:options:context: when using nullMocks.
I get the error:
I'm using
:head
in my Podfile to get the latest Kiwi.The text was updated successfully, but these errors were encountered: