title: Angular Jasmine spyOn $resource Unexpected request
body: <p>I am unit testing an Angular controller which calls a service to get json data.  I'm using Jasmine spyOn to spy on my service's query method like this:</p>
  
  <pre><code>spyOn facilitiesService, 'query'
      .and
      .callFake (success, error) -&gt;
          deferred.promise.then success
          deferred.promise.catch error
          $promise: deferred.promise
  </code></pre>
  
  <p>I have defined a mock backend for running in the browser during development, that intercepts real REST calls, and uses <code>$resource(path/to.json).query()</code> to return fake data.  Whenever I have the mock backend enabled, browser testing works fine, but my unit tests fail with unexpected request when I do <code>scope.$digest()</code>.  How is the mock backend being called when I am spying on the method?</p>
  
  <p>I would like this configuration to work with the mock backend specified so I can watch files and run unit tests before updating the application in the browser.</p>
  
  <p>UPDATE:</p>
  
  <p><a href="http://plnkr.co/edit/hVc2YNnwUDNv7IHODOMD?p=preview" rel="nofollow">http://plnkr.co/edit/hVc2YNnwUDNv7IHODOMD?p=preview</a></p>
  
  <p>Here is a plunker I created that shows the behavior I'm seeing.  Why is $httpBackend's whenGET method even being called?</p>
  
  <p>I have seen other examples where they create a mock service that only contains empty methods to be spied on, but in that case, what is the point of spyOn's callFake if you already have a fake service, just put the callFake logic in the fake service's methods, and don't bother with spying.</p>