diff --git a/jasmine.iws b/jasmine.iws index cf9e1f9..ccf5cf4 100644 --- a/jasmine.iws +++ b/jasmine.iws @@ -89,10 +89,10 @@ - + - + @@ -107,10 +107,10 @@ - + - + @@ -449,16 +449,16 @@ - + - + - + - + diff --git a/lib/jasmine.js b/lib/jasmine.js index bba075b..96156ee 100755 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -18,6 +18,46 @@ if (typeof Function.method !== 'function') { } } +var actionCollection = function () { + var that = { + actions: [], + index: 0, + finished: false, + + execute: function () { + if (that.actions.length > 0) { + that.next(); + } + }, + + getCurrentAction: function () { + return that.actions[that.index]; + }, + + next: function() { + if (that.index < that.actions.length) { + var currentAction = that.getCurrentAction(); + currentAction.execute(); + that.waitForDone(currentAction); + } else { + that.finished = true; + } + }, + + waitForDone: function(action) { + var id = setInterval(function () { + if (action.finished) { + clearInterval(id); + that.index++; + that.next(); + } + }, 150); + } + } + + return that; +} + /****************************************************************************** * Jasmine ******************************************************************************/ @@ -150,106 +190,24 @@ var waits = function (timeout) { var then = runs; - - - - var describe = function (description, spec_definitions) { - var that = { - description: description, - specs: [], - specIndex: 0, - finished: false, + var that = actionCollection(); - execute: function () { - if (that.specs.length > 0) { - that.next(); - } - }, - - getCurrentSpec: function () { - return that.specs[that.specIndex]; - }, - - next: function() { - if (that.specIndex < that.specs.length) { - var currentSpec = that.getCurrentSpec(); - currentSpec.execute(); - that.waitForDone(currentSpec); - } - else { - that.finished = true; - } - }, - - waitForDone: function(spec) { - var id = setInterval(function () { - if (spec.finished) { - clearInterval(id); - that.specIndex++; - that.next(); - } - }, 150); - } - } + that.description = description; + that.specs = that.actions; currentSuite = that; currentRunner.suites.push(that); - spec_definitions(); + spec_definitions(); + return that; } +var Jasmine = function () { + var that = actionCollection(); -/* - * Jasmine constructor - */ -//var jasmine_init = function () { -// return { -// results: [] -// } -//} - -/* - * Jasmine instance - */ -//var Jasmine = jasmine_init(); - - -var Jasmine = function() { - var that = { - suites: [], - suiteIndex: 0, - - execute: function () { - if (that.suites.length > 0) { - that.next(); - } - }, - - getCurrentSuite: function () { - return that.suites[that.suiteIndex]; - }, - - next: function() { - if (that.suiteIndex < that.suites.length) { - var currentSuite = that.getCurrentSuite(); - currentSuite.execute(); - that.waitForDone(currentSuite); - } - }, - - waitForDone: function(suite) { - var id = setInterval(function () { - if (suite.finished) { - clearInterval(id); - that.suiteIndex++; - that.next(); - } - }, 150); - } - } - + that.suites = that.actions; currentRunner = that; return that; } @@ -259,7 +217,6 @@ var currentSuite = describe('default current suite', function() {}); var currentSpec; - /* * TODO: * - add spec or description to results @@ -272,8 +229,8 @@ var currentSpec; * - Suite supports after_each * - Suite rolls up spec results //* - Suite supports asynch - * - Runner that runs suites in order - * - Runner supports async + //* - Runner that runs suites in order +// * - Runner supports async * - HTML reporter * - Shows pass/fail progress (just like bootstrap reporter) * - Lists a Summary: total # specs, # of passed, # of failed