Permalink
Browse files

* Spaces => Tabs :)

  • Loading branch information...
1 parent c7987e6 commit e4e4bee754b4ed68bde32e317ed9b36fc290cfc0 @cpojer cpojer committed Jul 21, 2010
Showing with 63 additions and 65 deletions.
  1. +2 −1 MIT.LICENSE
  2. +61 −64 src/JasmineAdapter.js
View
3 MIT.LICENSE
@@ -1,6 +1,7 @@
-Copyright (c) 2008
+Copyright (c) 2010
Misko Hevery <misko@hevery.com>
Olmo Maldonado <me@ibolmo.com>
+ Christoph Pojer <christoph.pojer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
125 src/JasmineAdapter.js
@@ -6,82 +6,79 @@
(function(describe, it, beforeEach, afterEach, addResult){
- var frame = function(parent, name){
- var caseName = '';
- if (parent && parent.caseName) caseName = parent.caseName + ' ';
- if (name) caseName += name;
+var frame = function(parent, name){
+ var caseName = '';
+ if (parent && parent.caseName) caseName = parent.caseName + ' ';
+ if (name) caseName += name;
var before = [],
after = [];
- return {
- name: name,
- caseName: caseName,
- parent: parent,
- testCase: TestCase(caseName),
- before: before,
- after: after,
- runBefore: function(){
- if (parent) parent.runBefore.apply(this);
- for (var i = 0, l = before.length; i < l; i++) before[i].apply(this);
- },
- runAfter: function(){
- for (var i = 0, l = after.length; i < l; i++) after[i].apply(this);
- if (parent) parent.runAfter.apply(this);
- }
- };
- };
-
- var currentFrame = frame(null, null);
-
- jasmine.Env.prototype.describe = function(description, context){
- currentFrame = frame(currentFrame, description);
- var result = describe.call(this, description, context);
- currentFrame = currentFrame.parent;
- return result;
+ return {
+ name: name,
+ caseName: caseName,
+ parent: parent,
+ testCase: TestCase(caseName),
+ before: before,
+ after: after,
+ runBefore: function(){
+ if (parent) parent.runBefore.apply(this);
+ for (var i = 0, l = before.length; i < l; i++) before[i].apply(this);
+ },
+ runAfter: function(){
+ for (var i = 0, l = after.length; i < l; i++) after[i].apply(this);
+ if (parent) parent.runAfter.apply(this);
+ }
};
-
- jasmine.Env.prototype.it = function(description, closure){
- var result = it.call(this, description, closure);
- var currentSpec = this.currentSpec;
+};
- var frame = this.jstdFrame = currentFrame;
- var name = 'test that it ' + description;
-
- if (this.jstdFrame.testCase.prototype[name])
- throw "Spec with name '" + description + "' already exists.";
- this.jstdFrame.testCase.prototype[name] = function(){
- jasmine.getEnv().currentSpec = currentSpec;
- frame.runBefore.apply(currentSpec);
- try {
- closure.apply(currentSpec);
- } finally {
- frame.runAfter.apply(currentSpec);
- }
- };
- return result;
- };
+var currentFrame = frame(null, null);
+jasmine.Env.prototype.describe = function(description, context){
+ currentFrame = frame(currentFrame, description);
+ var result = describe.call(this, description, context);
+ currentFrame = currentFrame.parent;
+ return result;
+};
+
+jasmine.Env.prototype.it = function(description, closure){
+ var result = it.call(this, description, closure),
+ currentSpec = this.currentSpec,
+ frame = this.jstdFrame = currentFrame,
+ name = 'test that it ' + description;
- jasmine.Env.prototype.beforeEach = function(closure) {
- beforeEach.call(this, closure);
- currentFrame.before.push(closure);
- };
+ if (this.jstdFrame.testCase.prototype[name])
+ throw "Spec with name '" + description + "' already exists.";
+ this.jstdFrame.testCase.prototype[name] = function(){
+ jasmine.getEnv().currentSpec = currentSpec;
+ frame.runBefore.apply(currentSpec);
+ try {
+ closure.apply(currentSpec);
+ } finally {
+ frame.runAfter.apply(currentSpec);
+ }
+ };
+ return result;
+};
- jasmine.Env.prototype.afterEach = function(closure) {
- afterEach.call(this, closure);
- currentFrame.after.push(closure);
- };
+jasmine.Env.prototype.beforeEach = function(closure) {
+ beforeEach.call(this, closure);
+ currentFrame.before.push(closure);
+};
+jasmine.Env.prototype.afterEach = function(closure) {
+ afterEach.call(this, closure);
+ currentFrame.after.push(closure);
+};
- jasmine.NestedResults.prototype.addResult = function(result) {
- addResult.call(this, result);
- if (result.type != 'MessageResult' && !result.passed()) fail(result.message);
- };
+jasmine.NestedResults.prototype.addResult = function(result) {
+ addResult.call(this, result);
+ if (result.type != 'MessageResult' && !result.passed()) fail(result.message);
+};
- // Reset environment with overriden methods.
- jasmine.currentEnv_ = null;
- jasmine.getEnv();
+// Reset environment with overriden methods.
+jasmine.currentEnv_ = null;
+jasmine.getEnv();
})(jasmine.Env.prototype.describe, jasmine.Env.prototype.it, jasmine.Env.prototype.beforeEach, jasmine.Env.prototype.afterEach, jasmine.NestedResults.prototype.addResult);

0 comments on commit e4e4bee

Please sign in to comment.