diff options
| author | Misko Hevery | 2010-05-25 14:23:52 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-05-25 14:23:52 -0700 |
| commit | 5992e81b2e302c3b3375567e347227f6a9496585 (patch) | |
| tree | 754f22bc649905c5265f66e8f78a0b5d49e9af38 /src/scenario | |
| parent | 2cce1ffc15ae6483da9cf354f7a5d2d26317427e (diff) | |
| download | angular.js-5992e81b2e302c3b3375567e347227f6a9496585.tar.bz2 | |
added rake task to create a single file for scenario runner
Diffstat (limited to 'src/scenario')
| -rw-r--r-- | src/scenario/DSL.js | 1 | ||||
| -rw-r--r-- | src/scenario/Runner.js | 18 | ||||
| -rw-r--r-- | src/scenario/angular.prefix | 30 | ||||
| -rw-r--r-- | src/scenario/angular.suffix | 11 | ||||
| -rw-r--r-- | src/scenario/bootstrap.js | 9 |
5 files changed, 59 insertions, 10 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js index 842f7c7a..8cbb256d 100644 --- a/src/scenario/DSL.js +++ b/src/scenario/DSL.js @@ -5,6 +5,7 @@ angular.scenario.dsl.browser = { self.testFrame.load(function(){ self.testFrame.unbind(); self.testDocument = jQuery(self.testWindow.document); + self.testWindow = self.testFrame[0].contentWindow; done(); }); if (this.testFrame.attr('src') == url) { diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js index 8669f56b..01e16e79 100644 --- a/src/scenario/Runner.js +++ b/src/scenario/Runner.js @@ -1,11 +1,10 @@ -angular['scenario'] = (angular['scenario'] = {}); -angular.scenario['dsl'] = (angular.scenario['dsl'] = {}); +angular['scenario'] = angular['scenario'] || (angular['scenario'] = {}); +angular.scenario['dsl'] = angular.scenario['dsl'] || (angular.scenario['dsl'] = {}); angular.scenario.Runner = function(scope, jQuery){ var self = scope.$scenario = this; this.scope = scope; this.jQuery = jQuery; - angular.extend(scope, angular.scenario.dsl); var specs = this.specs = {}; var path = []; @@ -30,7 +29,7 @@ angular.scenario.Runner = function(scope, jQuery){ self.currentSpec = null; }; this.logger = function returnNoop(){ - return angular.extend(returnNoop, {close:angular.noop, fail:angular.noop});; + return _(returnNoop).extend({close:_.identity, fail:_.identity});; }; }; @@ -60,7 +59,7 @@ angular.scenario.Runner.prototype = { var element = jQuery('<li class="running '+type+'"><span></span></li>'); element.find('span').text(text); container.append(element); - return angular.extend(logger(element), { + return _(logger(element)).extend({ close: function(){ element.removeClass('running'); if(!element.hasClass('fail')) @@ -81,7 +80,7 @@ angular.scenario.Runner.prototype = { } this.logger = logger(console); var specNames = []; - angular.foreach(this.specs, function(spec, name){ + _(this.specs).each(function(spec, name){ specNames.push(name); }, this); specNames.sort(); @@ -109,7 +108,7 @@ angular.scenario.Runner.prototype = { result.passed = false; result.failed = true; result.error = error; - result.log('fail', angular.isString(error) ? error : angular.toJson(error)).fail(); + result.log('fail', _(error).isString() ? error : toJson(error)).fail(); } }; specThis = { @@ -122,11 +121,11 @@ angular.scenario.Runner.prototype = { function done() { result.finished = true; stepLogger.close(); - (callback||angular.noop).call(specThis); + (callback||_.identity).call(specThis); } function next(){ var step = spec.steps[spec.nextStepIndex]; - (result.log || {close:angular.noop}).close(); + (result.log || {close:_.identity}).close(); result.log = null; if (step) { spec.nextStepIndex ++; @@ -134,6 +133,7 @@ angular.scenario.Runner.prototype = { try { step.fn.call(specThis, next); } catch (e) { + console.error(e); result.fail(e); done(); } diff --git a/src/scenario/angular.prefix b/src/scenario/angular.prefix new file mode 100644 index 00000000..5b44e17c --- /dev/null +++ b/src/scenario/angular.prefix @@ -0,0 +1,30 @@ +/** + * The MIT License + * + * Copyright (c) 2010 Adam Abrons and Misko Hevery http://getangular.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +(function(window, document, previousOnLoad){ + window.angular = { + scenario: { + dsl: window + } + }; + diff --git a/src/scenario/angular.suffix b/src/scenario/angular.suffix new file mode 100644 index 00000000..fc861cbf --- /dev/null +++ b/src/scenario/angular.suffix @@ -0,0 +1,11 @@ + + var $scenarioRunner = new angular.scenario.Runner(window, jQuery); + + window.onload = function(){ + try { + if (previousOnLoad) previousOnLoad(); + } catch(e) {} + $scenarioRunner.run(jQuery(window.document.body)); + }; + +})(window, document, window.onload); diff --git a/src/scenario/bootstrap.js b/src/scenario/bootstrap.js index 4c9cdc8d..694d0e97 100644 --- a/src/scenario/bootstrap.js +++ b/src/scenario/bootstrap.js @@ -18,6 +18,12 @@ document.write('<link rel="stylesheet" type="text/css" href="' + prefix + path + '"/>'); } + window.angular = { + scenario: { + dsl: window + } + }; + window.onload = function(){ _.defer(function(){ $scenarioRunner.run(jQuery(window.document.body)); @@ -27,8 +33,9 @@ addCSS("../../css/angular-scenario.css"); addScript("../../lib/underscore/underscore.js"); addScript("../../lib/jquery/jquery-1.4.2.js"); - addScript("../angular-bootstrap.js"); addScript("Runner.js"); + addScript("../Angular.js"); + addScript("../JSON.js"); addScript("DSL.js"); document.write('<script type="text/javascript">' + '$scenarioRunner = new angular.scenario.Runner(window, jQuery);' + |
