title: Unit testing in AngularJS with mock $resource
body: <p>Trying to get some units tests in AngularJS (using jasmine &amp; karma) working and struggling to comprehend dependency  injection... current error message in karma reads 'Error: Argument 'fn' is not a function, got string'</p>
  
  <p>app.js</p>
  
  <pre><code>angular.module('App', [ 'App.Services', 'App.Controllers', 'App.Directives']);
  </code></pre>
  
  <p>controller.js</p>
  
  <pre><code>angular.module('App.Controllers', []).
  controller('MarketplaceCtrl', function ($scope, apiCall) {
      apiCall.query({
          type: 'engagement',
          engagement_status__in: '0,1'
      }, function(data) {
          var engagements = {};
          $.each(data.objects, function (i, engagement) {
             engagements[engagement.lawyer_id] = engagement
          });
          $scope.engagements = engagements;
      });
  });
  </code></pre>
  
  <p>services.js</p>
  
  <pre><code>angular.module('App.Services', ['ngResource']).
  factory('apiCall', function ($resource) {
      return $resource('/api/v1/:type',
          {type: '@type'},
          {
              query: {
                  method: 'GET',
                  isArray: false
              }
          }
      );
  });
  </code></pre>
  
  <p>controllerSpec.js</p>
  
  <pre><code>describe('controllers', function () {
  
      beforeEach(
          module('App', ['App.Controllers', 'App.Directives', 'App.Services'])
      );
  
      describe('MarketplaceCtrl', function () {
          var scope, ctrl, $httpBackend;
  
          beforeEach(inject(function (_$httpBackend_, $rootScope, $controller) {
              $httpBackend = _$httpBackend_;
              $httpBackend.expectGET('/api/v1/engagement?engagement_status__in=0,1').
                  respond([]);
              scope = $rootScope.$new();
              /* Why is MarketplaceCtrl not working? :( */
              ctrl = $controller('MarketplaceCtrl', {$scope: scope});
          }));
  
          it('should have a MarketplaceCtrl controller', (function () {
              expect(ctrl).not.to.equal(null);
          }));
      });
  });
  </code></pre>