title: Unable to unit test $http method
body: <p>I have a simple controller method like this</p>
  
  <pre><code>$scope.testMethod= function (urlPost) {
      var obj= {
              headers: {
                  'Content-Type': 'application/json'
              },
              method: 'POST',
              data: $scope.prjObj,
              url: urlPost
          };
        if (obj!= undefined) {
             $http(obj).then(function (response) {
             console.log(respone)
            }) 
        //rest of the code
        }}
  </code></pre>
  
  <p>I am trying to test this method</p>
  
  <pre><code> beforeEach(angular.mock.inject(function ($injector) {
              $httpBackend = $injector.get('$httpBackend');
              var x ={
                  key:'value'
              }
              $httpBackend.when("POST",'/path/to/url',x).respond(200, ["Toyota"]);
   // Rest of the code
  })
  
  it("Should check for the testMethod",function(){
  
          var x ={key:"value"
          }
          $httpBackend.expect('POST','/path/to/url',x).respond({ hello: 'World' });
          createController();
          scope.testMethod("pathToUrl");
  
          $httpBackend .flush()
  
      })
  </code></pre>
  
  <p>I follower <a href="https://stackoverflow.com/questions/33509431/how-do-i-mock-http-in-angularjs-service-jasmine-test">this</a> ,<a href="https://stackoverflow.com/questions/42789183/how-to-mock-http-post-method-that-has-been-called-in-other-service-method-in-ja">this</a>,<a href="https://stackoverflow.com/questions/34730887/testing-a-service-function-post-response-with-jasmine">this</a> , <a href="https://stackoverflow.com/questions/32482645/angularjs-jasmine-mock-unit-test-http-factory-of-post-method">this</a> &amp; numerous online resources, but it is still throwing</p>
  
  <pre><code>Error: Unexpected request: [object Object] undefined
      Expected POST /path/to/url
          at $httpBackend (node_modules/angular-mocks/angular-mocks.js:1323:9)
          at ChildScope.$scope.addEditProject (testCtrl.js:9:11770)
          at UserContext.&lt;anonymous&gt; (testCtrl-spec.js:201:15)
  </code></pre>
  
  <p>Any idea where I am making mistake?</p>