title: $httpBackend not stubbing the request/response?
body: <p>I am trying to test my <code>$scope.init(id)</code> function. In this function I make a request to my API that returns an array of objects, so I want to stub it out with a preset response.</p>
  
  <p>This is my failing test:</p>
  
  <pre><code>describe('mysite', function() {
    var scope, MensDetailCtrl, $httpBackend;
    beforeEach(function() {
      module('mysite');
    });
  
    describe('MensDetailCtrl', function() {
      beforeEach(inject(function($controller, $rootScope, $injector) {
        scope = $rootScope.$new();
  
        $httpBackend = $injector.get('$httpBackend');
        $httpBackend.when('GET', '/api/products/1').respond({name: 'product_name'});
  
        MensDetailCtrl = $controller('MensDetailCtrl', {
          '$scope': scope
        });
      }));
  
  
      describe('init(id)', function() {
        it('sets scope.product', function() {
          scope.init(1);
          console.log(scope.product.name); // HERE: prints undefined
          expect(scope.product).toBeDefined();
        });
  
  
      });
  
  
    });
  
  });
  </code></pre>
  
  <p>And this is my controller:</p>
  
  <pre><code>app.controller('MensDetailCtrl', ['$scope', '$resource', '$controller', 'Product', function($scope, $resource, $controller, Product) {
    $controller('ProductsDetailCtrl', {$scope: $scope});
  
  
    $scope.init = function(id)
    {
      console.log("zzzzz"); // this is printed
      $scope.product = Product.get({productId: id}, function(data) {
        console.log("here!!!"); // this is not printed
      });
  
    }
     ...
  
  }]);
  </code></pre>
  
  <p>And my factory:</p>
  
  <pre><code>app.factory('Product', ['$resource', function($resource) {
    return $resource("/api/products/:productId", {}, {
      query: {method: 'GET', isArray: true},
    });
  }]);
  </code></pre>
  
  <p>Didn't I already stub it out with this <code>$httpBackend.when('GET', '/api/products/1').respond({name: 'product_name'});</code>?</p>