title: When to use spy vs $httpBackend in jasmine
body: <p>I'm writing <code>Jasmine</code> code to test some <code>Restangular</code> logic.  I want to test that my 'Foo' <code>object</code> has been Restangulraized, so that the <code>foo.getList()</code> method will call <code>GET /foo</code> and return the result</p>
  
  <p>I could test this in two ways.  I could add a <code>.spy</code> on <code>foo.getList()</code> and have it return the expected results.  Alternatively I can use <code>$HttpBackend.whenGET("/foo")</code> and set my expected results there.  </p>
  
  <p>Is one of these considered preferable?</p>
  
  <p>I would assume <code>HTTPBackend</code> would be the better option, since it test 'later' in the logic flow. If I used a <code>spy</code> I couldn't prove, for example, that my Restangularize hadn't screwed up and was trying to resolve a different URL. </p>
  
  <p>However, I'm looking at the inherited tests and they all use <code>spy</code>, and since I assume the person who wrote this code is better than me (they can't be more newbie then me at Angular) it makes me wonder if there is an advantage to the use of <code>spy</code> over <code>$httpBackend</code>.</p>