Skip to content
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

Support stubs and expectations on mocks for methods from categories #437

Open
adubr opened this issue Jan 29, 2014 · 3 comments
Open

Support stubs and expectations on mocks for methods from categories #437

adubr opened this issue Jan 29, 2014 · 3 comments
Labels

Comments

@adubr
Copy link

adubr commented Jan 29, 2014

The following test fails

@interface NSObject (Category)

-(void)doSomethingWith:(NSString*)str;

@end

@implementation NSObject (Category)

- (void)doSomethingWith:(NSString *)str {
  NSLog(@"%@", str);
}

@end

SPEC_BEGIN(NSObjectCategory)

describe(@"NSObjectCategory", ^{
  it(@"does receive the real message but this test fails ", ^{
    id mock = [NSObject mock];
    [[[mock should] receive] doSomethingWith:@"string"];
    [mock doSomethingWith:@"string"];
  });
});

SPEC_END

stubbing -doSomethingWith: doesn't work neither, the real method is called. This behavior seems wrong, especially considering that if I change id mock = [NSObject mock]; to id obj = [NSObject new]; the test succeeds.

@modocache modocache added the Bug label Feb 13, 2014
@modocache
Copy link
Member

Sorry for the delay, @adubr. I've just tried this locally and it does indeed appear to be a bug.

Thanks for the heads up! I'll post back here once it's fixed in master.

@adubr
Copy link
Author

adubr commented Feb 14, 2014

@modocache, finding a bug is the least I could do : ) Thanks for such a great tool!

@Panajev
Copy link

Panajev commented Feb 23, 2014

Great find :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants