title: How to unit test api calls using AFNetworking
body: <p>I have an iOS app I'm working on, which connects to a third-party web service. I have around 50 different calls, and want to write unit tests using Kiwi, but I have no idea where to start.</p>
  
  <p>As I'm not responsible for the API, I need to just check that my calls are pointing to the correct URL, using the correct GET or POST method.</p>
  
  <p>Is there any way to test this properly?</p>
  
  <p>Heres an example of one of my calls:</p>
  
  <pre><code>+ (void)listsForUser:(NSString *)username
              response:(void (^)(NSArray *lists))completion
  {
      NSString *path = [NSString stringWithFormat:@"user/list.json/%@/%@", TRAKT_API_KEY, username];
      [TNTraktAPIManager requestWithMethod:GET
                                      path:path
                                parameters:nil
                                  callback:^(id response) {
                                      completion(response);
                                  }];
  }
  </code></pre>
  
  <p>Which calls the following helper method</p>
  
  <pre><code>+ (void)requestWithMethod:(HTTPMethod)method
                       path:(NSString *)path
                 parameters:(NSDictionary *)params
                   callback:(void (^)(id response))completion
  {
      NSString *methodString = @"POST";
      if (method == GET) {
          methodString = @"GET";
      }
  
  
      // Setup request
      NSURLRequest *request = [[TraktAPIClient sharedClient] requestWithMethod:methodString
                                                                          path:path
                                                                    parameters:params];
  
      // Setup operation
      AFJSONRequestOperation *operation =
      [AFJSONRequestOperation JSONRequestOperationWithRequest:request
                                                      success:^(NSURLRequest *request,
                                                                NSHTTPURLResponse *response,
                                                                id JSON) {
                                                          id jsonResults = JSON;
                                                          completion(jsonResults);
  
                                                      } failure:^(NSURLRequest *request,
                                                                  NSHTTPURLResponse *response,
                                                                  NSError *error,
                                                                  id JSON) {
  
                                                          id jsonResults = JSON;
                                                          completion(jsonResults);
                                                          NSLog(@"%s: error: %@", __PRETTY_FUNCTION__, error);
  
                                                      }];
      // TODO: Queue operations
      [operation start];
  
  }
  </code></pre>