title: iphone OCMockObject and unit-testing a class that inherits from NSURLConnection
body: <p>I want to unit test the custom init method of a class that inherits from NSURLConnection -- how would I do this if the init of my testable class invokes <code>NSURLConnection's initWithRequest</code>?</p>
  
  <p>I'm using OCMock and normally, I can mock objects that are contained within my test class. For this inheritance scenario, what's the best approach to do this?</p>
  
  <pre><code>- (void)testInit
  {   
      id urlRequest = [OCMockObject mockForClass:[NSURLRequest class]];
  
      MyURLConnectionWrapper *conn = [[MyURLConnectionWrapper alloc] 
                      initWithRequest:urlRequest delegate:self 
                      someData:extraneousData];
  }
  </code></pre>
  
  <p>My class is implemented like this:</p>
  
  <pre><code>@interface MyURLConnectionWrapper : NSURLConnection {
  
  }
  - (id)initWithRequest:(NSURLRequest *)request 
               delegate:(id)delegate someData:(NSString *)fooData
  @end
  
  @implementation MyURLConnectionWrapper
  
  - (id)initWithRequest:(NSURLRequest *)request 
               delegate:(id)delegate someData:(NSString *)fooData
  {
      if (self = [super initWithRequest:request delegate:delegate]) 
      {
          // do some additional work here
      }
  
      return self;
  }
  </code></pre>
  
  <p>Here's the error I get:</p>
  
  <blockquote>
    <p>OCMockObject[NSURLRequest]: unexpected
    method invoked: _CFURLRequest</p>
  </blockquote>