Skip to content

ragaskar/iSpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iSpy is a port of Jasmine's spies for ScrewUnit

Basic usage (if you've placed iSpy in /public/javascripts/iSpy):

require('/javascripts/iSpy/lib/iSpy');
require('/javascripts/iSpy/lib/jquery.print');
require('/javascripts/iSpy/plugins/screw.iSpy');

Screw.Unit(function () {
  describe('Basic Example', function() {
    it('should replace the specified function with a spy object', function() {
      var TestClass = {
        someFunction: function() {
          originalFunctionWasCalled = true;
        }
      };
      spyOn(TestClass, 'someFunction');

      expect(TestClass.someFunction).to_not(have_been_called);
      expect(TestClass.someFunction.callCount).to(equal, 0);
      TestClass.someFunction('foo');
      expect(TestClass.someFunction).to(have_been_called);
      expect(TestClass.someFunction.callCount).to(equal, 1);
      expect(TestClass.someFunction.mostRecentCall.args).to(equal, ['foo']);
      expect(TestClass.someFunction.mostRecentCall.object).to(equal, TestClass);

      TestClass.someFunction('bar');
      expect(TestClass.someFunction.callCount).to(equal, 2);
      expect(TestClass.someFunction.mostRecentCall.args).to(equal, ['bar']);
    });
  });
});

Thanks go to Christian Williams for writing the original version of spies for Jasmine.

About

Lightweight mocking/stubbing/spying framework for Screw.Unit (ported from jasmine)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published