title: Can't get OHHTTPStubs to work with NSURLSession
body: <p>I'm trying to use OHHTTPStubs in my XCTest class,</p>
  
  <p>This is how I configured <code>OHTTPStubs</code> in my test file.</p>
  
  <pre><code>//
  // Tests Configuration
  //
  - (void)setUp
  {
      [super setUp];
      _bundle = [NSBundle bundleForClass:[self class]];
      [self configureHTTPStubs];
      [self installHTTPStubs];
  }
  
  - (void)configureHTTPStubs
  {
      [OHHTTPStubs onStubActivation:^(NSURLRequest *request, id&lt;OHHTTPStubsDescriptor&gt; stub) {
          NSLog(@"[OHHTTPStubs] Request to %@ has been stubbed with %@", request.URL, stub.name);
      }];
  }
  
  - (void)installHTTPStubs
  {
      HIAPIRequests *requester = [[HIAPIOperator sharedOperator] requester];
      [OHHTTPStubs setEnabled:YES forSessionConfiguration:requester.session.configuration];
      [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
          return [request.URL.path isEqualToString:@"/image_upload"];
      } withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
          return [[OHHTTPStubsResponse responseWithFileAtPath:OHPathForFileInBundle(@"image_upload_ws_response.json", nil)
                                                   statusCode:201
                                                      headers:@{@"Content-Type":@"text/json"}] responseTime:OHHTTPStubsDownloadSpeed3G];
      }].name = @"Image Upload OK";
  
  }
  
  //
  // In my Requester class this is how I setup the NSURLSession configuration
  //
  - (void)configureURLSession
  {
      NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
      _session = [NSURLSession sessionWithConfiguration:config];
  }
  </code></pre>
  
  <p>And this is how I'm performing a request</p>
  
  <pre><code>- (void)uploadImage:(UIImage *)image
      completionBlock:(operationCompletionBlock)completionBlock
        progressBlock:(operationProgressBlock)progressBlock
  {
      NSData *imageData = UIImageJPEGRepresentation(image, 0.80);
      NSURLRequest *request = [NSURLRequest requestWithURLString:@"/image_upload"];
      NSURLSessionUploadTask *uploadTask = [_session uploadTaskWithRequest:request
                                                              fromData:imageData
                                                     completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                         completionBlock(data, error);
                                                     }];
  
      [_progressTable setObject:progressBlock forKey:uploadTask];
      [uploadTask resume];
  }
  </code></pre>
  
  <p>In the <code>completionHandler</code> callback I'm basically getting a no domain found error (<code>error   NSURLError *    domain: @"NSURLErrorDomain" - code: -1003   0x08a70740</code>) , <code>@"A server with the specified hostname could not be found."</code></p>
  
  <p>I'm completely sure that I'm querying the correct URL (the one I stubbed with <code>OHHTTPStubs</code>) in my test.</p>
  
  <p>What could be going on here? Bug maybe?</p>