title: When unit testing a directive how to pass its controller
body: <p>I am new to AngularJS and its unit test. Currently I am trying to test a directive with its controller in the template file:</p>
  
  <p>It's template:</p>
  
  <pre><code>&lt;div ng-controller = "SomeController" &gt;
  &lt;select ng-model="data.selectedOption" 
          ng-options="data.code for data in data.availableOptions track by data.code"&gt;
  &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>It's js file:</p>
  
  <pre><code>angular.module('application.directives')
    .directive('selector', function () {
      return {
        restrict: 'E',
        templateUrl: 'templates.html'
       };
    });
  </code></pre>
  
  <p>Now I have a unit test like: </p>
  
  <pre><code>describe('selector', function () {
    beforeEach(module('application.directives','application.templates'));
  
    it('render the correct number of items', inject(function ($rootScope, $compile) {
      var element = $compile('&lt;selector&gt;&lt;/selector&gt;')($rootScope);
      $rootScope.$digest();
      //I'd like to register the selector's controller here.
    }));
  });
  </code></pre>
  
  <p>In the test code, what would be the best way to register the controller? Do I need to create a mock one?</p>
  
  <p>Thanks</p>