Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Kiwi Helper Class Question


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.


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;
describe(@"SomeClass", ^{
__block SomeHelper* tester;
__block SomeClass* theClass;
tester = [[SomeHelper alloc] init];
it(@"can utilize the helper", ^{
/** ... some setup ... **/
[tester shouldHave:7 OfSomethingOn:theClass];
@implementation SomeHelper
-(void) shouldHave:(int)expectedCount OfSomethingOn:(SomeClass)someObject
/** ERROR: should is not avialable **/
[[theValue([someObject theCount]) should] equal:theValue(expectedCount)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment