Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c expectFutureValue失败_Objective C_Cocoa_Kiwi - Fatal编程技术网

Objective c expectFutureValue失败

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

为什么我不能通过考试?未调用任何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: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];
    });
});