Skip to content

Instantly share code, notes, and snippets.

@mmertsock
Created May 5, 2013 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmertsock/5519408 to your computer and use it in GitHub Desktop.
Save mmertsock/5519408 to your computer and use it in GitHub Desktop.
@interface TestClass1 : NSObject
+ (NSString *)getSomeString;
- (NSString *)doSomething;
- (NSString *)doSomethingElse;
@end
@interface TestClass1 (TestClass1Catgegory)
+ (NSString *)ext_getSomeString:(NSString *)input;
@end
@implementation TestClass1
+ (NSString *)getSomeString
{
return @"getSomeStringResult";
}
- (NSString *)doSomething
{
return [TestClass1 getSomeString];
}
- (NSString *)doSomethingElse
{
return [TestClass1 ext_getSomeString:@"ext"];
}
@end
@implementation TestClass1 (TestClass1Catgegory)
+ (NSString *)ext_getSomeString:(NSString *)input
{
return [input stringByAppendingString:@"-got"];
}
@end
SPEC_BEGIN(ShouldReceiveSpec)
describe(@"Attempt to repor 'MagicalRecord MR_createInContext: returns nil'", ^{
it(@"should not return nil when using shouldReceive on a class method", ^{
TestClass1 *object = [TestClass1 new];
[[[TestClass1 class] should] receive:@selector(getSomeString)];
NSString *result = [object doSomething];
[[result should] equal:@"getSomeStringResult"];
});
it(@"should not return nil when using shouldReceive on a class method defined in a category", ^{
TestClass1 *object = [TestClass1 new];
[[[TestClass1 class] should] receive:@selector(ext_getSomeString:)];
NSString *result = [object doSomethingElse];
[[result should] equal:@"ext-got"];
});
});
SPEC_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment