title: Spy on a constructor using jasmine
body: <p>I want to spy on a constructor function and tell how many times it's been called using jasmine. I'd usually do something like this to target a method of an object:</p>
  
  <pre><code>spyOn(lib,'methodName')
  </code></pre>
  
  <p>but in the case I'm trying to spy on the actualy constructor so I've tried:</p>
  
  <pre><code>spyOn(lib);
  
  
   it('lib should be instantiated for each matching element', function () {
      spyOn(lib);
      expect(lib.calls.count()).toEqual(2);
  });
  </code></pre>
  
  <p>Unfortunately this just gives me an error in the console:</p>
  
  <pre><code>"Error: undefined() method does not exist in ..."
  </code></pre>
  
  <p>how can I spy on the constructor?</p>