title: AngularJS Karma testing "Error: Unexpected request: GET" doesn't seem to be executing request
body: <p>I have an AngularJS app that is having some issues in testing.  </p>
  
  <p><strong>Method</strong></p>
  
  <pre><code>PlanService.prototype.getPlanList = function() {
    this.activeRequest = true;
    return this.PlanFactory.planList().then((function(_this) {
      return function(response) {
        _this.plans = response.plans;
        return _this.activeRequest = false;
      };
    })(this));
  };
  
  return PlanService;
  </code></pre>
  
  <p><strong>Unit test:</strong></p>
  
  <pre><code>var planService;
  beforeach(function() {
    module("notRealModuleName");
    inject(function(PlanService) {
      planService = PlanService;
    });
  });
  
  ...(other tests)
  
  it('should get a list of plans', function() {
    var $httpBackend;
    inject(function($injector) {
      $httpBackend = $injector.get('$httpBackend');
    });
  
    var plans = {"plans": [array of stuff goes here]};
    $httpBackend.whenGET('/plans/special').respond(plans);
    var promise = planService.getPlanList();
  
    promise.then(function(response) {
       expect(response).toBeDefined();
       expect(planService.plans).toBeDefined();
    });
    $httpBackend.flush();
  });
  </code></pre>
  
  <p>When this test executes, the error <code>Error: Unexpected request: GET http://ip_address/plans/special No more request expected</code> is returned.  If I comment out the the <code>httpBackend.flush</code>, the test passes.  However, if I change the <code>expect(planService.plans)</code> to a non-existent method, it doesn't fail.  Clearly, the expectations are not being called.  What's wrong with this?</p>