Angular directive link function not running in Jasmine test

Angular directive link function not running in Jasmine test.

by JamieMason

HTML

<script src="http://jasmine.github.io/1.3/lib/jasmine.js"></script>
<script src="http://jasmine.github.io/1.3/lib/jasmine-html.js"></script>
<link rel="stylesheet" href="http://jasmine.github.io/1.3/lib/jasmine.css">
<script src="https://code.angularjs.org/1.4.0/angular.js"></script>
<script src="https://code.angularjs.org/1.4.0/angular-mocks.js"></script>

JavaScript

//--- CODE --------------------------

(function() {

    angular.module('myApp', [])
        .directive('appFoo', appFoo);

    function appFoo() {

        console.log('Directive Factory runs');

        return {
            controller: AppFooController,
            link: link,
            replace: true,
            restrict: 'E',
            scope: {
                parentProp: '='
            }
        };

        function AppFooController($scope) {

            console.log('Controller runs');

            $scope.render({
                some: 'data'
            });

        }

        function link($scope, $element) {

            console.log('Link function runs');

            $scope.render = function(data) {
                console.log(shared.$scope.parentProp, $element[0], data);
            };

        }

    }

}());

// --- SPECS -------------------------

describe('myApp::appFoo', function() {

    var shared;

    beforeEach(function() {

        shared = {};
        shared.markup = '<app-foo parent-prop="someProp"></app-foo>';

        inject(function($compile, $rootScope) {
            shared.$compile = $compile;
            shared.$parentScope = $rootScope.$new(true);
            shared.$rootScope = $rootScope;
        });

        shared.createDirective = function() {
            shared.$element = angular.element(shared.markup);
            shared.$compile(shared.$element)(shared.$parentScope);
            shared.$parentScope.$digest();
            shared.el = shared.$element[0];
            shared.$childScope = shared.$element.scope();
        };

    });

    describe('when compiled', function() {

        describe('when all parameters are provided', function() {

            beforeEach(function() {
                shared.$parentScope.someProp = {
                    a: 'a',
                    b: 'b'
                };
                shared.createDirective();
            });

            it('should have a render method', function() {
        ...