Comment faire pour modifier la valeur de retour de jasmin espion?

Je suis en utilisant le Jasmin pour créer un espion comme suit:

beforeEach(inject(function ($injector) {
    $rootScope = $injector.get('$rootScope');
    $state = $injector.get('$state');
    $controller = $injector.get('$controller');

    socket = new sockMock($rootScope);

    //this is the line of interest
    authService = jasmine.createSpyObj('authService', ['login', 'logout', 'currentUser']);
}));

Je voudrais être en mesure de changer ce qui est retourné par les diverses méthodes de authService.

Voici comment les tests sont mis en place:

function createController() {
    return $controller('UserMatchingController', {'$scope': $rootScope, 'socket':socket, 'authService': authService });
}

describe('on initialization', function(){
    it('socket should emit a match', function() {
        createController();

        expect(socket.emits['match'].length).toBe(1);
    });

    it('should transition to users.matched upon receiving matched', function(){

        //this line fails with "TypeError: undefined is not a function"
        authService.currentUser.andReturn('bob');

        createController();

        $state.expectTransitionTo('users.matched');
        socket.receive('matchedblah', {name: 'name'});

        expect(authService.currentUser).toHaveBeenCalled()
    })
})

Voici comment le contrôleur est configuré:

lunchrControllers.controller('UserMatchingController', ['$state', 'socket', 'authService',
    function ($state, socket, authService) {
        socket.emit('match', {user: authService.currentUser()});

        socket.on('matched' + authService.currentUser(), function (data) {
            $state.go('users.matched', {name: data.name})
        });
    }]);

Essentiellement, je voudrais être en mesure de modifier la valeur de retour de la espionné méthodes. Cependant, je ne suis pas sûr si je suis correctement l'approche du problème par l'utilisation de jasmine.createSpyObj.

  • Quelle est la version de Jasmin?
  • J'ai "jasmine-core": "~2.2.0" dans package.json