From 5dda723185a9037b7e92828d32430c21838ee216 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 10 May 2010 20:24:20 -0700 Subject: improved handling of text fields when formater fails to prevent clobering of field --- lib/jasmine-jstd-adapter/JasmineAdapter.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jasmine-jstd-adapter/JasmineAdapter.js b/lib/jasmine-jstd-adapter/JasmineAdapter.js index ba54251a..0fdc4612 100644 --- a/lib/jasmine-jstd-adapter/JasmineAdapter.js +++ b/lib/jasmine-jstd-adapter/JasmineAdapter.js @@ -9,7 +9,7 @@ function bind(_this, _function){ return function(){ return _function.call(_this); - } + }; } var currentFrame = frame(null, null); @@ -49,14 +49,22 @@ })(jasmine.Env.prototype.describe); + var id = 0; jasmine.Env.prototype.it = (function(it){ return function(desc, itFn){ var self = this; var spec = it.apply(this, arguments); var currentSpec = this.currentSpec; + if (!currentSpec.$id) { + currentSpec.$id = id++; + } var frame = this.jstdFrame = currentFrame; - this.jstdFrame.testCase.prototype['test that it ' + desc] = function(){ + var name = 'test that it ' + desc; + if (this.jstdFrame.testCase.prototype[name]) + throw "Spec with name '" + desc + "' already exists."; + this.jstdFrame.testCase.prototype[name] = function(){ + jasmine.getEnv().currentSpec = currentSpec; frame.runBefore.apply(currentSpec); try { itFn.apply(currentSpec); -- cgit v1.2.3