Objective c expectFutureValue失败
为什么我不能通过考试?未调用任何AFHTTPRequestOperation块。expectFutureValue似乎不等待结果并立即返回。我正在尝试XCode 6.1和Kiwi 2.3.1 谢谢Objective c expectFutureValue失败,objective-c,cocoa,kiwi,Objective C,Cocoa,Kiwi,为什么我不能通过考试?未调用任何AFHTTPRequestOperation块。expectFutureValue似乎不等待结果并立即返回。我正在尝试XCode 6.1和Kiwi 2.3.1 谢谢 context(@"AFNetworking", ^{ it(@"stubs a request with an error", ^{ NSError *error = [NSError errorWithDomain:@"com.luisobo.nocilla" code:1
context(@"AFNetworking", ^{
it(@"stubs a request with an error", ^{
NSError *error = [NSError errorWithDomain:@"com.luisobo.nocilla" code:123 userInfo:@{NSLocalizedDescriptionKey:@"Failing, failing... 1, 2, 3..."}];
stubRequest(@"POST", @"https://example.com/say-hello").
withHeaders(@{ @"X-MY-AWESOME-HEADER": @"sisisi", @"Content-Type": @"text/plain" }).
withBody(@"Adios!").
andFailWithError(error);
NSURL *url = [NSURL URLWithString:@"https://example.com/say-hello"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"sisisi" forHTTPHeaderField:@"X-MY-AWESOME-HEADER"];
[request setHTTPBody:[@"Adios!" dataUsingEncoding:NSASCIIStringEncoding]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
__block BOOL succeed = NO;
__block BOOL failed = NO;
__block NSError *capturedError = nil;
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
succeed = YES;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
capturedError = error;
failed = YES;
}];
[operation start];
[[expectFutureValue(theValue(failed)) shouldEventually] beYes];
});
});