title: mock angularjs service for unit testing using jasmine
body: <p>I have an Angular App and I want to create  unit test cases for it using <strong>jasmine</strong>.<br> 
  In my <strong>AngularJS</strong> app, I have a service as : <br></p>
  
  <pre><code>var canceler;
  var myServices = angular.module('myServices', ['ngResource'])
  
  myServices.factory('getData', ['$http', '$q', function($http, $q){
      var canceler;
      return {
          setData: function(url, callback, error) {
                      canceler = $q.defer();
                      $http.post(url, {}, {timeout:canceler.promise}).success(callback).error(error);
          },
          abort: function(){ canceler.resolve();}
      }
  }]);
  </code></pre>
  
  <p>This service is being used by controller.</p>
  
  <p>Now how can I provide a mock for this <strong>"getData"</strong> service to the injector I am using in controllerSpecs.js (for the unit testing using jasmine).</p>
  
  <p>For the reference, the code of controllerSpecs.js is defined in  <a href="https://stackoverflow.com/questions/21252369/getting-error-while-using-jasmine-with-angularjs/">Getting error while using Jasmine with AngularJS</a>.</p>