title: Jasmine: no pending request to flush
body: <p>I was following the instructions of the course 'Hands on agular' (<a href="https://code.tutsplus.com/courses/hands-on-angular" rel="nofollow">https://code.tutsplus.com/courses/hands-on-angular</a>), wrote the following controller test:</p>
  
  <pre><code>'use strict';
  describe('Controller: EventsController', function () {
  
    // load the controller's module
    beforeEach(module('ekApp'));
  
    var EventsController,
      scope, http, response;
  
    // Initialize the controller and a mock scope
    beforeEach(inject(function ($controller, $rootScope, $httpBackend) {
      http = $httpBackend;
      response = [{ key: '1' }];
      http.whenGET('/api/events').respond(response);
      scope = $rootScope.$new();
      EventsController = $controller('EventsController', {
        $scope: scope
        // place here mocked dependencies
      });
    }));
  
    afterEach(function(){
        http.verifyNoOutstandingExpectation();
        http.verifyNoOutstandingRequest();
    });
  
    it('should request to api', function () {
        http.expectGET('/api/events');
        http.flush();
    });
  });
  </code></pre>
  
  <p>When i run this test, i get 'no pending request to flush' error...</p>
  
  <p>Here is my EventsController:</p>
  
  <pre><code>'use strict';
  
  angular.module('ekApp')
  .controller('EventsController', function($scope, Event, Category){
      $scope.categories = [{name: 'All'}];
  
      $scope.serverCategories = Category.query(function(){
          $scope.categories = $scope.categories.concat($scope.serverCategories);
      });
  
      console.log($scope.categories);
  
      $scope.events = Event.query();
  
      console.log($scope.events);
  
      $scope.filterBy = {
          search: '',
          category: $scope.categories[0],
          startDate: new Date(2015,4,1),
          endDate: new Date(2016,1,14)
      };
  });
  </code></pre>
  
  <p>and my Event service, which returns resource:</p>
  
  <pre><code>'use strict';
  
  angular
      .module('ekApp')
      .factory('Event', function($resource){
          return $resource('/api/events/:id', { id: '@id' });
      });
  </code></pre>