forked from kiwi-bdd/Kiwi
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKWSharedExample.m
More file actions
40 lines (31 loc) · 1.1 KB
/
Copy pathKWSharedExample.m
File metadata and controls
40 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Licensed under the terms in License.txt
//
// Copyright 2014 Allen Ding. All rights reserved.
//
#import "KWSharedExample.h"
#import "KWSharedExampleRegistry.h"
#import "KWExample.h"
@implementation KWSharedExample
#pragma mark - Initializing
- (id)initWithName:(NSString *)name block:(KWSharedExampleBlock)block {
NSParameterAssert(name);
NSParameterAssert(block);
self = [super init];
if (self) {
_name = name;
_block = block;
}
return self;
}
@end
#pragma mark - Building Example Groups
void sharedExamplesFor(NSString *name, KWSharedExampleBlock block) {
KWSharedExample *sharedExample = [[KWSharedExample alloc] initWithName:name block:block];
[[KWSharedExampleRegistry sharedRegistry] registerSharedExample:sharedExample];
}
void itBehavesLike(NSString *name, Class describedClass) {
KWSharedExample *sharedExample = [[KWSharedExampleRegistry sharedRegistry] sharedExampleForName:name];
NSString *description = [NSString stringWithFormat:@"behaves like %@", sharedExample.name];
context(description, ^{ sharedExample.block(describedClass); });
}