title: Using Jasmine to spy on a function without an object
body: <p>I'm new to Jasmine and have just started using it. I have a library js file with lots of functions which are not associated with any object (i.e. are global). How do I go about spying on these functions?</p>
  
  <p>I tried using window/document as the object, but the spy did not work even though the function was called. I also tried wrapping it in a fake object as follows :</p>
  
  <pre><code>var fakeElement = {};
  fakeElement.fakeMethod = myFunctionName;
  spyOn(fakeElement, "fakeMethod");
  </code></pre>
  
  <p>and test with</p>
  
  <pre><code>expect(fakeElement.fakeMethod).toHaveBeenCalled();
  </code></pre>
  
  <p>This does not work either as the spy did not work</p>