title: Jasmine spyon method returning undefined
body: <p>I am getting an undefined error on my SpyOn method</p>
  
  <p>This was what I had come up with </p>
  
  <pre><code>    'use strict';
  describe('WebApp: AccountController', function() {
    return beforeEach(function() {
      module('webApp');
      module('tpls');
      return inject(function($injector) {
        this.q = $injector.get('$q');
        this.userMock = {
          id: 1,
          email: 'pidsafs@gmail.com',
          name: 'Adones Pitogo'
        };
        this.modalMock = {
          open: (function(_this) {
            return function(tpl, ctrl) {
              _this.def = _this.q.defer();
              _this.def.resolve(true);
              return {
                result: _this.def.promise
              };
            };
          })(this)
        };
        this.teamMock = {
          id: 1
        };
        this.repoMock = {
          id: 1
        };
        this.httpBackend = $injector.get('$httpBackend');
        this.httpBackend.whenGET('/api/v1/session').respond({
          status: 'ok',
          user: this.userMock
        });
        this.httpBackend.whenGET("/api/v1/users/" + this.userMock.id + "/teams").respond({
          status: 'ok',
          teams: [this.teamMock]
        });
        this.httpBackend.whenGET("/api/v1/users/" + this.userMock.id + "/repositories/remote").respond({
          status: 'ok',
          repositories: []
        });
        this.httpBackend.whenGET("/api/v1/users/" + this.userMock.id + "/repositories/followed").respond({
          status: 'ok',
          repositories: []
        });
        this.InvoiceService = $injector.get('Common.InvoiceService');
        this.TeamService = $injector.get('Common.TeamService');
        this.RepositoryService = $injector.get('Common.RepositoryService');
        this.UserService = $injector.get('Common.UserService');
        this.rootScope = $injector.get('$rootScope');
        this.scope = this.rootScope.$new();
        this.scope.user = this.userMock;
        this.$controller = $injector.get('$controller');
        this.timeout = $injector.get('$timeout');
        this.compile = $injector.get('$compile');
        this.rootElement = $injector.get('$rootElement');
        this.toasterMock = {
          pop: function(type, title, message) {
            return true;
          }
        };
        this.modalSpy = spyOn(this.modalMock, 'open').andCallThrough();
        this.httpBackend.flush();
        $('body').append('&lt;div id="profile-pic-input"&gt;&lt;/div&gt;');
        this.openFileWindow = function() {
          return this.timeout(function() {
            return $('#profile-pic-input').trigger('click');
          });
        };
        this.controller = this.$controller('AccountController', {
          '$scope': this.scope,
          '$rootScope': this.rootScope,
          'Common.RepositoryService': this.RepositoryService,
          'Common.UserService': this.UserService,
          'Common.InvoiceService': this.InvoiceService,
          'toaster': this.toasterMock,
          'openFileWindow': this.openFileWindow,
          'Common.TeamService': this.TeamService
        });
        return this.scope.$digest();
      });
    });
  });
  </code></pre>
  
  <p>I always get this error </p>
  
  <pre><code>TypeError: 'undefined' is not a function (evaluating 'spyOn(this.modalMock, 'open').andCallThrough()')
  </code></pre>
  
  <p>It happens if I spy on all the other services as well</p>