Skip to content

Instantly share code, notes, and snippets.

@nicktoumpelis
Created August 13, 2014 09:34
Show Gist options
  • Save nicktoumpelis/bff97452c1c9dcd60e5f to your computer and use it in GitHub Desktop.
Save nicktoumpelis/bff97452c1c9dcd60e5f to your computer and use it in GitHub Desktop.
Kiwi Spec Template
#import "Kiwi.h"
static NSTimeInterval const kAsynchronousTestingTimeout = 2.0;
SPEC_BEGIN(KlassSpec)
describe(@"An object", ^{
context(@"when...", ^{
__block Klass *object = nil;
beforeAll(^{ // or 'beforeEach', depending on your needs
object = [Klass new];
});
it(@"should not be nil", ^{
[[object shouldNot] beNil];
});
// ...
context(@"when doing some other stuff...", ^{
it(@"should...", ^{
id delegateMock = [KWMock mockForProtocol:@protocol(KlassDelegate)];
[[delegateMock stub] didUpdateKlass:any()];
object.delegate = delegateMock;
[[[delegateMock shouldEventuallyBeforeTimingOutAfter(kAsynchronousTestingTimeout)] receive] didUpdateKlass:object];
[object update];
});
it(@"should...", ^{
[object update];
[[expectFutureValue(object.stuff) shouldNotEventuallyBeforeTimingOutAfter(kAsynchronousTestingTimeout)] beNil];
[[expectFutureValue(theValue([object.stuff count])) shouldNotEventuallyBeforeTimingOutAfter(kAsynchronousTestingTimeout)] beZero];
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment