AFNetworking/Tests/AFHTTPRequestOperationTest.m
Blake Watters 4f04b35378 Reorganize testing setup
* Eliminate static library and framework targets
* Migrate all testing infrastructure and code to Tests/
* Nest CocoaPods setup for testing under Tests/
* Remove explicit dependencies from shared schemes
2013-05-11 13:18:43 -04:00

42 lines
1.5 KiB
Objective-C

//
// AFHTTPRequestOperationTest.m
// AFNetworking
//
// Created by Blake Watters on 5/10/13.
// Copyright (c) 2013 AFNetworking. All rights reserved.
//
#import "AFNetworkingTests.h"
@interface AFHTTPRequestOperationTest : SenTestCase
@end
@implementation AFHTTPRequestOperationTest
- (void)testThatOperationInvokesSuccessCompletionBlockWithResponseObjectOnSuccess
{
__block id blockResponseObject = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:AFNetworkingTestsBaseURL()]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
blockResponseObject = responseObject;
} failure:nil];
[operation start];
expect([operation isFinished]).will.beTruthy();
expect(blockResponseObject).willNot.beNil();
}
- (void)testThatOperationInvokesFailureCompletionBlockWithErrorOnFailure
{
__block NSError *blockError = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/404" relativeToURL:AFNetworkingTestsBaseURL()]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) {
blockError = error;
}];
[operation start];
expect([operation isFinished]).will.beTruthy();
expect(blockError).willNot.beNil();
}
@end