title: Why can't i access directive's scope in jasmine test?
body: <p>Here's my directive:</p>
  
  <pre><code>angular.module('app')
      .directive('statusFilter',statusFilter);
  
  function statusFilter() {
      return {
          restrict: 'E',
          replace: true,
          templateUrl: 'app/directives/status-filter.html',
          scope: {
              flags: '='
          },
          controller: function($scope, $element, $timeout, $document) {
  
              function isChildElement(el) {
                  return $.contains($element[0], el);
              }
  
              function close(event) {
                  if (!isChildElement(event.target)) {
                      $scope.$apply(function() {
                          $scope.isOpen = false;
                      });
                      $document.off('mouseup', close);
                  }
              }
  
              function updateFlags(value) {
                  for (var prop in $scope.flagsClone) {
                      $scope.flagsClone[prop] = value;
                  }
              }
  
              function pullFlags() {
                  $scope.flagsClone = $.extend(true, {}, $scope.flags);
              }
  
              function pushFlags() {
                  for (var prop in $scope.flagsClone) {
                      $scope.flags[prop] = $scope.flagsClone[prop];
                  }
              }
  
              $scope.isOpen = false;
              $scope.flagsClone = {};
  
              pullFlags();
  
              $scope.apply = function() {
                  pushFlags();
                  $scope.isOpen = false;
              };
  
              $scope.selectAll = function() {
                  updateFlags(true);
              };
  
              $scope.selectNone = function() {
                  updateFlags(false);
              };
  
              $scope.open = function() {
                  if (!$scope.isOpen) {
                      pullFlags();
                      $scope.isOpen = true;
  
                      $timeout(function() {
                          $document.on('mouseup', close);
                      });
                  }
              };
          }
  
      };
  
  }
  </code></pre>
  
  <p>Here's a simple test i wrote for it:</p>
  
  <pre><code>describe('status-filter directive', function() {
      beforeEach(module('app'));
  
      var template = '&lt;status-filter flags="filters"&gt;&lt;/status-filter&gt;';
      var scope, element;
  
  
      beforeEach(inject(function($rootScope, $compile) {
          scope = $rootScope.$new();
          var ngElement = angular.element(template);
          element = $compile(ngElement)(scope);
          scope.$digest();
      }));
  
      it('Should open when isOpen is true', function() {
          scope.open();
          scope.$digest();
  
          expect(scope.isOpen).toBe(true);
  
  
      });
  });
  </code></pre>
  
  <p>I cannot access the directive's scope no matter how i try. Like in the example above, .isolateScope(), element.scope(). With anything i try i get <code>open() is undefined</code> error. What is wrong in my code?</p>