Skip to content

Commit

Permalink
Integrate Jasmine for automated Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian committed Sep 8, 2010
1 parent 72fab64 commit 6d5ab6a
Show file tree
Hide file tree
Showing 10 changed files with 5,066 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Packager
Submodule Packager updated 3 files
+6 −6 helpers/array.php
+7 −7 packager
+21 −21 packager.php
53 changes: 53 additions & 0 deletions assets/JSSpecToJasmine.js
@@ -0,0 +1,53 @@
value_of = expect;

(function(prototype){

prototype.should_be = prototype.toEqual;
prototype.should_not_be = prototype.toNotEqual;

prototype.should_be_true = prototype.toBeTruthy;
prototype.should_be_false = prototype.toBeFalsy;
prototype.should_be_null = prototype.toBeNull;
prototype.should_match = prototype.toMatch;
prototype.should_be_empty = function(){
return !this.actual || (this.actual.length == 0);
};

})(jasmine.Matchers.prototype);

describe = (function(original){
var each = 'before each',
all = 'before all',
after = 'after all';

return function(name, object){
if (object instanceof Function){
original(name, object);
return;
}

original(name, function(){
var beforeAll = object[all],
bfEach = object[each],
aAll = object[after];

beforeEach(function(){
if (beforeAll){
beforeAll();
beforeAll = null;
}

if (bfEach) bfEach();
});

delete object[all];
delete object[each];
delete object[after];

for (var key in object)
it(key, object[key]);

if (aAll) it('cleans up', aAll);
});
};
})(describe);

0 comments on commit 6d5ab6a

Please sign in to comment.