mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-19 14:21:02 +00:00
added rake task to create a single file for scenario runner
This commit is contained in:
parent
2cce1ffc15
commit
5992e81b2e
8 changed files with 93 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ externs.js
|
|||
angular.js
|
||||
angular-minified.js
|
||||
angular-debug.js
|
||||
angular-scenario.js
|
||||
|
|
|
|||
26
Rakefile
26
Rakefile
|
|
@ -3,7 +3,7 @@ include FileUtils
|
|||
task :default => [:compile, :test]
|
||||
|
||||
desc 'Generate Externs'
|
||||
task :compileexterns do
|
||||
task :compile_externs do
|
||||
out = File.new("externs.js", "w")
|
||||
|
||||
out.write("function _(){};\n")
|
||||
|
|
@ -29,9 +29,31 @@ task :compileexterns do
|
|||
out.close
|
||||
end
|
||||
|
||||
desc 'Compile Scenario'
|
||||
task :compile_scenario do
|
||||
concat = %x(cat \
|
||||
lib/underscore/underscore.js \
|
||||
lib/jquery/jquery-1.4.2.js \
|
||||
src/scenario/angular.prefix \
|
||||
src/Angular.js \
|
||||
src/JSON.js \
|
||||
src/scenario/Runner.js \
|
||||
src/scenario/DSL.js \
|
||||
src/scenario/angular.suffix \
|
||||
)
|
||||
css = %x(cat css/angular-scenario.css)
|
||||
f = File.new("angular-scenario.js", 'w')
|
||||
f.write(concat)
|
||||
f.write('document.write(\'<style type="text/css">\n')
|
||||
f.write(css.gsub(/'/, "\\'").gsub(/\n/, "\\n"));
|
||||
f.write('\n</style>\');')
|
||||
f.close
|
||||
end
|
||||
|
||||
desc 'Compile JavaScript'
|
||||
task :compile do
|
||||
Rake::Task['compileexterns'].execute 0
|
||||
Rake::Task['compile_externs'].execute 0
|
||||
Rake::Task['compile_scenario'].execute 0
|
||||
|
||||
concat = %x(cat \
|
||||
src/angular.prefix \
|
||||
|
|
|
|||
9
scenario/Runner-compiled.html
Normal file
9
scenario/Runner-compiled.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<script type="text/javascript" src="../angular-scenario.js"></script>
|
||||
<script type="text/javascript" src="widgets-scenario.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
30
src/scenario/angular.prefix
Normal file
30
src/scenario/angular.prefix
Normal file
|
|
@ -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
|
||||
}
|
||||
};
|
||||
|
||||
11
src/scenario/angular.suffix
Normal file
11
src/scenario/angular.suffix
Normal file
|
|
@ -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);
|
||||
9
src/scenario/bootstrap.js
vendored
9
src/scenario/bootstrap.js
vendored
|
|
@ -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);' +
|
||||
|
|
|
|||
Loading…
Reference in a new issue