Slide 37
Slide 37 text
__block (Kiwi example)
describe(@"it takes a while"
, ^{
__block NSDictionary *apiResponse = nil;
beforeAll(^{
__block BOOL requestCompleted = NO;
AFJSONRequestOperation *operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:
request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
requestCompleted = YES;
apiResponse = JSON;
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
requestCompleted = YES;
}
];
[operation start];
[KWSpec waitWithTimeout:3.0 forCondition:
^BOOL() {
return requestCompleted;
}];
});
it(@"includes the related objects in the response"
, ^{
[[[apiResponse objectForKey:
@"children"
] should] containObjects:
@"foo", @"bar", @"baz", nil];
});
});