title: How can I spy on element?
body: <p>Let's say I have this directive:</p>
  
  <pre><code>.directive 'panelcreator', -&gt;
      (scope, element)-&gt;
          element.bind 'mouseenter', -&gt;
              element.addClass 'alert alert-danger'
  </code></pre>
  
  <p>To keep this a  unit spec, I want to stub out <code>element.addClass</code>, right? So how do I go about doing this?</p>
  
  <p>My attempt:</p>
  
  <pre><code>describe 'panelcreator', -&gt;
  
      describe 'something', -&gt;
          beforeEach -&gt;
              spyOn(element, 'addClass')
              element.trigger('mouseenter')
  
          it 'shoud create a panel', -&gt;
              expect(element.addClass).toHaveBeenCalledWith 'alert alert-danger'      
  </code></pre>
  
  <p>Gives me:</p>
  
  <pre><code>Error: Expected a spy, but got Function.
  </code></pre>
  
  <p>How do I go about analysing a variable such as <code>element</code> in future so I can find out the method chain I need to pass <code>SpyOn</code>?</p>