title: How can I unit test isolated scope in directive
body: <p>I am trying to unit test a simple directive but the variable in the scope is always undefined.</p>
  
  <p>Directive Src Code:</p>
  
  <pre><code>.directive('ratingButton', ['$rootScope',
  
  
  function($rootScope) {
        return {
            restrict: "E",
            replace: true,
            template: '&lt;button type="button" class="btn btn-circle" ng-class="getRatingClass()"&gt;&lt;/button&gt;',
            scope: {
                buttonRating: "="
            },
            link: function(scope, elem, attr) {
                scope.getRatingClass = function() {
                    if (!scope.buttonRating)
                        return '';
                    else if (scope.buttonRating.toUpperCase() === 'GREEN')
                        return 'btn-success';
                    else if (scope.buttonRating.toUpperCase() === 'YELLOW')
                        return 'btn-warning warning-text';
                    else if (scope.buttonRating.toUpperCase() === 'RED')
                        return 'btn-danger';
                    else if (scope.buttonRating.toUpperCase() === 'BLUE')
                        return 'btn-info';
                }
            }
        };
    }])
  </code></pre>
  
  <p>Test:</p>
  
  <pre><code>describe('Form Directive: ratingButton', function() {
  
      // load the controller's module
      beforeEach(module('dashboardApp'));
  
      var scope,
          element;
  
      // Initialize the controller and a mock scope
      beforeEach(inject(function($compile, $rootScope) {
          scope = $rootScope.$new();
  
          //set our view html.
          element = angular.element('&lt;rating-button button-rating="green"&gt;&lt;/rating-button&gt;');
          $compile(element)(scope);
          scope.$digest();
      }));
  
      it('should return appropriate class based on rating', function() {
          //console.log(element.isolateScope());
          expect(element.isolateScope().buttonRating).toBe('green');
          expect(element.isolateScope().getRatingClass()).toBe('btn-success');
  
      });
  
  });
  </code></pre>
  
  <p>I used similar code in another directive unit test I had by passing values through element attributes and it worked as expected. For this test buttonRating is always undefined not sure where to go from here(I am fairly new with Jasmine/Karma)</p>
  
  <p>Any help would be great!</p>