Skip to content

Instantly share code, notes, and snippets.

@quirkey
Created March 21, 2009 04:45
Show Gist options
  • Select an option

  • Save quirkey/82730 to your computer and use it in GitHub Desktop.

Select an option

Save quirkey/82730 to your computer and use it in GitHub Desktop.
(function($) {
$.extend(jqUnit, {
// like rspec/bacon describe, sort of
describe: function() {
var args = [].splice.call(arguments, 0);
return jqUnit.module('describe: ' + args.join(' '));
},
// shortcut to append 'should' to tests
should: function(name, callback, nowait) {
return jqUnit.test('should ' + name, callback, nowait);
},
// asserts that the method is defined (like respond_to?)
defined: function(object, method) {
return jqUnit.ok(typeof object[method] != 'undefined', method + 'is not defined on' + object);
},
// asserts that the object is of a certain type
isType: function(object, type) {
return jqUnit.ok(object.constructor === type, object + 'is not of type' + type);
}
});
})(jQuery);
(function($) {
with(jqUnit) {
describe('My.Application', 'init');
should('initialize with function', function() {
ok(true);
});
should('return an application object', function() {
ok(true);
});
describe('My.Application', 'foo');
should('be awesome', function() {
ok(true);
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment