Skip to content

Instantly share code, notes, and snippets.

@leviwilson
Last active August 29, 2015 14:05
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 leviwilson/4d71da404b4fdffccce1 to your computer and use it in GitHub Desktop.
Save leviwilson/4d71da404b4fdffccce1 to your computer and use it in GitHub Desktop.
Kiwi Helper Class Question

Background

Warning: I do not know objective-c that well

I'm working in some specs. Sometimes I see an opportunity to use some test helpers to eliminate some duplication in my testing. I'd like to be able to create a helper class that is able to wrap some of these helper verification methods and re-use it to clean up some of my specs.

Problem

I don't have access to any of the should flavor of Kiwi verifications within my tester. I'm assuming because I'm not within the SPEC_BEGIN / SPEC_END (as those macros call other Kiwi methods).

The Question

What do I need to do in order to create a helper class to be able to utilize the should macros in Kiwi?

#import "Kiwi.h"
@interface SomeHelper : NSObject
-(void) shouldHave:(int)expectedCount OfSomethingOn:(SomeClass)someObject;
@end
SPEC_BEGIN(SomeClassSpec)
describe(@"SomeClass", ^{
__block SomeHelper* tester;
__block SomeClass* theClass;
beforeEach(^{
theClass
tester = [[SomeHelper alloc] init];
});
it(@"can utilize the helper", ^{
/** ... some setup ... **/
[tester shouldHave:7 OfSomethingOn:theClass];
});
});
SPEC_END
@implementation SomeHelper
-(void) shouldHave:(int)expectedCount OfSomethingOn:(SomeClass)someObject
{
/** ERROR: should is not avialable **/
[[theValue([someObject theCount]) should] equal:theValue(expectedCount)];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment