extjs-mvc 0.3.10 → 0.4.0.a
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +5 -173
- data/Rakefile +18 -20
- data/VERSION +1 -1
- data/bin/xmvc +13 -0
- data/lib/extjs-mvc/README +20 -0
- data/lib/extjs-mvc/builder.rb +83 -0
- data/lib/extjs-mvc/builders/all_builder.rb +15 -0
- data/lib/extjs-mvc/builders/app_builder.rb +36 -0
- data/lib/extjs-mvc/builders/base.rb +138 -0
- data/lib/extjs-mvc/builders/css_builder.rb +36 -0
- data/lib/extjs-mvc/builders/docs_builder.rb +20 -0
- data/lib/extjs-mvc/builders/mvc_builder.rb +33 -0
- data/lib/extjs-mvc/builders/plugin_builder.rb +53 -0
- data/lib/extjs-mvc/cli.rb +52 -0
- data/lib/extjs-mvc/generator.rb +79 -0
- data/lib/extjs-mvc/generators/app.rb +57 -0
- data/lib/extjs-mvc/generators/base.rb +53 -0
- data/lib/extjs-mvc/generators/controller.rb +41 -0
- data/lib/extjs-mvc/generators/model.rb +41 -0
- data/lib/extjs-mvc/generators/scaffold.rb +17 -0
- data/lib/extjs-mvc/generators/templates/Controller.js +17 -0
- data/lib/extjs-mvc/generators/templates/Model.js +9 -0
- data/lib/extjs-mvc/generators/templates/ModelSpec.js +12 -0
- data/lib/extjs-mvc/generators/templates/View.js +16 -0
- data/lib/extjs-mvc/generators/templates/_Action.js +7 -0
- data/lib/extjs-mvc/generators/templates/app/README.rdoc +152 -0
- data/lib/extjs-mvc/generators/templates/app/app/App.js +64 -0
- data/lib/extjs-mvc/generators/templates/app/app/controllers/ApplicationController.js +10 -0
- data/lib/extjs-mvc/generators/templates/app/app/controllers/HomeController.js +10 -0
- data/lib/extjs-mvc/generators/templates/app/app/views/home/Index.js +17 -0
- data/lib/extjs-mvc/generators/templates/app/app/views/layout/Menu.js +23 -0
- data/lib/extjs-mvc/generators/templates/app/config/application.js +1 -0
- data/lib/extjs-mvc/generators/templates/app/config/boot.js +67 -0
- data/lib/extjs-mvc/generators/templates/app/config/build.xml +77 -0
- data/lib/extjs-mvc/generators/templates/app/config/database.js +4 -0
- data/lib/extjs-mvc/generators/templates/app/config/environment.json +58 -0
- data/lib/extjs-mvc/generators/templates/app/config/environments/development.json +1 -0
- data/lib/extjs-mvc/generators/templates/app/config/environments/production.json +4 -0
- data/lib/extjs-mvc/generators/templates/app/config/routes.js +27 -0
- data/lib/extjs-mvc/generators/templates/app/config/settings.yml +3 -0
- data/lib/extjs-mvc/generators/templates/app/public/index.html +19 -0
- data/lib/extjs-mvc/generators/templates/app/public/stylesheets/ext-mvc-all.css +49 -0
- data/{test/active_record_test.rb → lib/extjs-mvc/generators/templates/app/spec/SpecHelper.js} +0 -0
- data/lib/extjs-mvc/generators/templates/app/spec/index.html +66 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/EXAMPLE.html +68 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/LICENSE +22 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/README.markdown +307 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/jquery-1.2.3.js +3408 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/jquery.fn.js +29 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/jquery.print.js +108 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.assets.js +36 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.behaviors.js +91 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.builder.js +80 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.css +90 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.events.js +42 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.matchers.js +145 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.server.js +21 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/behaviors_spec.js +178 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/matchers_spec.js +237 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/print_spec.js +119 -0
- data/{test/controller_test.rb → lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/spec_helper.js} +0 -0
- data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/suite.html +18 -0
- data/lib/extjs-mvc/generators/templates/scaffold/ScaffoldController.js +18 -0
- data/lib/extjs-mvc/generators/view.rb +29 -0
- data/lib/extjs-mvc/plugin.rb +105 -0
- data/lib/extjs-mvc/scripts.rb +15 -0
- data/lib/extjs-mvc/settings.rb +75 -0
- data/lib/extjs-mvc/setup.rb +5 -0
- data/lib/extjs-mvc/stats.rb +241 -0
- data/lib/extjs-mvc/test.rb +11 -0
- data/lib/extjs-mvc/testserver.ru +95 -0
- data/lib/extjs-mvc/ui.rb +58 -0
- data/lib/extjs-mvc/update.rb +73 -0
- data/lib/extjs-mvc.rb +70 -32
- data/lib/js/App.js +219 -0
- data/lib/js/MVC.js +260 -0
- data/lib/js/Presenter.js +52 -0
- data/lib/js/README.rdoc +69 -0
- data/lib/js/build +21 -0
- data/lib/js/controller/Controller.js +278 -0
- data/lib/js/controller/CrudController.js +460 -0
- data/lib/js/lib/Array.js +26 -0
- data/lib/js/lib/Booter.js +415 -0
- data/lib/js/lib/ClassManager.js +191 -0
- data/lib/js/lib/ControllerClassManager.js +95 -0
- data/lib/js/lib/Dependencies.js +44 -0
- data/lib/js/lib/DispatchMatcher.js +98 -0
- data/lib/js/lib/Dispatcher.js +129 -0
- data/lib/js/lib/Environment.js +43 -0
- data/lib/js/lib/Inflector.js +138 -0
- data/lib/js/lib/ModelClassManager.js +19 -0
- data/lib/js/lib/Route.js +139 -0
- data/lib/js/lib/Router.js +282 -0
- data/lib/js/lib/String.js +94 -0
- data/lib/js/lib/ViewClassManager.js +229 -0
- data/lib/js/lib/notes.txt +32 -0
- data/lib/js/model/AdapterManager.js +30 -0
- data/lib/js/model/Association.js +26 -0
- data/lib/js/model/Base.js +63 -0
- data/lib/js/model/BelongsToAssociation.js +116 -0
- data/lib/js/model/Cache.js +131 -0
- data/lib/js/model/HasManyAssociation.js +160 -0
- data/lib/js/model/Model.js +331 -0
- data/lib/js/model/UrlBuilder.js +106 -0
- data/lib/js/model/adapters/AbstractAdapter.js +296 -0
- data/lib/js/model/adapters/MemoryAdapter.js +103 -0
- data/lib/js/model/adapters/RESTAdapter.js +345 -0
- data/lib/js/model/adapters/RESTJSONAdapter.js +68 -0
- data/lib/js/model/adapters/notes.txt +42 -0
- data/lib/js/model/associations/Association.js +192 -0
- data/lib/js/model/associations/notes.txt +87 -0
- data/lib/js/model/validations/Errors.js +136 -0
- data/lib/js/model/validations/Plugin.js +139 -0
- data/lib/js/model/validations/Validations.js +276 -0
- data/lib/js/notes/Charts.graffle +0 -0
- data/lib/js/overrides/Ext.Component.js +21 -0
- data/lib/js/overrides/Ext.extend.js +142 -0
- data/lib/js/spec/Array.spec.js +15 -0
- data/lib/js/spec/ExtMVC.spec.js +65 -0
- data/lib/js/spec/Model.spec.js +370 -0
- data/lib/js/spec/OS.spec.js +83 -0
- data/lib/js/spec/Router.spec.js +99 -0
- data/lib/js/spec/SpecHelper.js +106 -0
- data/lib/js/spec/String.spec.js +83 -0
- data/lib/js/spec/model/AbstractAdapter.spec.js +49 -0
- data/lib/js/spec/model/Associations.spec.js +99 -0
- data/lib/js/spec/model/Cache.spec.js +5 -0
- data/lib/js/spec/model/RESTAdapter.spec.js +19 -0
- data/lib/js/spec/model/ValidationErrors.spec.js +64 -0
- data/lib/js/spec/model/Validations.spec.js +166 -0
- data/lib/js/spec/model/ValidationsPlugin.spec.js +108 -0
- data/lib/js/spec/suite.html +60 -0
- data/lib/js/specs-old/JSSpec.css +216 -0
- data/lib/js/specs-old/JSSpec.js +1512 -0
- data/lib/js/specs-old/all.html +66 -0
- data/lib/js/specs-old/base.js +14 -0
- data/lib/js/specs-old/controller.js +17 -0
- data/lib/js/specs-old/diff_match_patch.js +1 -0
- data/lib/js/specs-old/model.js +70 -0
- data/lib/js/specs-old/route.js +38 -0
- data/lib/js/specs-old/router.js +59 -0
- data/lib/js/specs-old/string.js +22 -0
- data/lib/js/testrunner/JSpecFormatter.js +111 -0
- data/lib/js/testrunner/TestClient.js +181 -0
- data/lib/js/testrunner/TestGrid.js +351 -0
- data/lib/js/testrunner/TestRunner.js +110 -0
- data/lib/js/testrunner/TestViewport.js +94 -0
- data/lib/js/vendor/screw-unit/EXAMPLE.html +68 -0
- data/lib/js/vendor/screw-unit/LICENSE +22 -0
- data/lib/js/vendor/screw-unit/README.markdown +307 -0
- data/lib/js/vendor/screw-unit/lib/jquery-1.2.3.js +3408 -0
- data/lib/js/vendor/screw-unit/lib/jquery.fn.js +29 -0
- data/lib/js/vendor/screw-unit/lib/jquery.print.js +108 -0
- data/lib/js/vendor/screw-unit/lib/screw.assets.js +36 -0
- data/lib/js/vendor/screw-unit/lib/screw.behaviors.js +91 -0
- data/lib/js/vendor/screw-unit/lib/screw.builder.js +80 -0
- data/lib/js/vendor/screw-unit/lib/screw.css +91 -0
- data/lib/js/vendor/screw-unit/lib/screw.events.js +42 -0
- data/lib/js/vendor/screw-unit/lib/screw.matchers.js +145 -0
- data/lib/js/vendor/screw-unit/lib/screw.server.js +21 -0
- data/lib/js/vendor/screw-unit/spec/behaviors_spec.js +178 -0
- data/lib/js/vendor/screw-unit/spec/matchers_spec.js +237 -0
- data/lib/js/vendor/screw-unit/spec/print_spec.js +119 -0
- data/{test/data_mapper_test.rb → lib/js/vendor/screw-unit/spec/spec_helper.js} +0 -0
- data/lib/js/vendor/screw-unit/spec/suite.html +18 -0
- data/lib/js/view/FormWindow.js +184 -0
- data/lib/js/view/HasManyEditorGridPanel.js +211 -0
- data/lib/js/view/scaffold/Edit.js +46 -0
- data/lib/js/view/scaffold/Index.js +561 -0
- data/lib/js/view/scaffold/New.js +20 -0
- data/lib/js/view/scaffold/ScaffoldFormPanel.js +255 -0
- data/test/helper.rb +10 -0
- data/test/test_extjs-mvc-gem.rb +7 -0
- metadata +232 -56
- data/README +0 -12
- data/lib/controller/controller.rb +0 -28
- data/lib/core_ext/array/extract_options.rb +0 -15
- data/lib/extjs/component.rb +0 -71
- data/lib/extjs/data/store.rb +0 -131
- data/lib/helpers/component.rb +0 -37
- data/lib/helpers/store.rb +0 -7
- data/lib/model/active_record.rb +0 -89
- data/lib/model/base.rb +0 -370
- data/lib/model/data_mapper.rb +0 -66
- data/lib/model/mongo_mapper.rb +0 -64
- data/lib/test/macros.rb +0 -20
- data/test/app/config/application.rb +0 -70
- data/test/app/config/database.yml +0 -3
- data/test/app/db/schema.rb +0 -75
- data/test/app/models/active_record/address.rb +0 -4
- data/test/app/models/active_record/data_type.rb +0 -3
- data/test/app/models/active_record/group.rb +0 -4
- data/test/app/models/active_record/house.rb +0 -4
- data/test/app/models/active_record/location.rb +0 -5
- data/test/app/models/active_record/person.rb +0 -4
- data/test/app/models/active_record/user.rb +0 -6
- data/test/app/models/active_record/user_group.rb +0 -4
- data/test/component_test.rb +0 -15
- data/test/debug.log +0 -2969
- data/test/model_test.rb +0 -526
- data/test/mongo_mapper_test.rb +0 -0
- data/test/store_test.rb +0 -0
- data/test/test_helper.rb +0 -32
@@ -0,0 +1,29 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.fn.fn = function() {
|
3
|
+
var self = this;
|
4
|
+
var extension = arguments[0], name = arguments[0];
|
5
|
+
if (typeof name == "string") {
|
6
|
+
return apply(self, name, $.makeArray(arguments).slice(1, arguments.length));
|
7
|
+
} else {
|
8
|
+
$.each(extension, function(key, value) {
|
9
|
+
define(self, key, value);
|
10
|
+
});
|
11
|
+
return self;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
function define(self, name, fn) {
|
15
|
+
self.data(namespacedName(name), fn);
|
16
|
+
};
|
17
|
+
function apply(self, name, args) {
|
18
|
+
var result;
|
19
|
+
self.each(function(i, item) {
|
20
|
+
var fn = $(item).data(namespacedName(name));
|
21
|
+
if (fn) result = fn.apply(item, args)
|
22
|
+
else throw(name + " is not defined");
|
23
|
+
});
|
24
|
+
return result;
|
25
|
+
};
|
26
|
+
function namespacedName(name) {
|
27
|
+
return 'fn.' + name;
|
28
|
+
}
|
29
|
+
})(jQuery);
|
@@ -0,0 +1,108 @@
|
|
1
|
+
(function($) {
|
2
|
+
|
3
|
+
function print_array(obj, opts) {
|
4
|
+
var result = [];
|
5
|
+
for (var i = 0; i < Math.min(opts.max_array, obj.length); i++)
|
6
|
+
result.push($.print(obj[i], $.extend({}, opts, { max_array: 3, max_string: 40 })));
|
7
|
+
|
8
|
+
if (obj.length > opts.max_array)
|
9
|
+
result.push((obj.length - opts.max_array) + ' more...');
|
10
|
+
if (result.length == 0) return "[]"
|
11
|
+
return "[ " + result.join(", ") + " ]";
|
12
|
+
}
|
13
|
+
|
14
|
+
function print_element(obj) {
|
15
|
+
if (obj.nodeType == 1) {
|
16
|
+
var result = [];
|
17
|
+
var properties = [ 'className', 'id' ];
|
18
|
+
var extra = {
|
19
|
+
'input': ['type', 'name', 'value'],
|
20
|
+
'a': ['href', 'target'],
|
21
|
+
'form': ['method', 'action']
|
22
|
+
};
|
23
|
+
$.each(properties.concat(extra[obj.tagName.toLowerCase()] || []), function() {
|
24
|
+
if (obj[this])
|
25
|
+
result.push(' ' + this.replace('className', 'class') + "=" + $.print(obj[this]))
|
26
|
+
});
|
27
|
+
return "<" + obj.tagName.toLowerCase()
|
28
|
+
+ result.join('') + ">";
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
function print_object(obj, opts) {
|
33
|
+
var seen = opts.seen || [];
|
34
|
+
|
35
|
+
var result = [], key, value;
|
36
|
+
for (var k in obj) {
|
37
|
+
if (obj.hasOwnProperty(k) && $.inArray(obj[k], seen) < 0) {
|
38
|
+
seen.push(obj[k]);
|
39
|
+
value = $.print(obj[k], $.extend({}, opts, { max_array: 6, max_string: 40, seen: seen }));
|
40
|
+
} else
|
41
|
+
value = "...";
|
42
|
+
result.push(k + ": " + value);
|
43
|
+
}
|
44
|
+
if (result.length == 0) return "{}";
|
45
|
+
return "{ " + result.join(", ") + " }";
|
46
|
+
}
|
47
|
+
|
48
|
+
function print_jquery(obj) {
|
49
|
+
}
|
50
|
+
|
51
|
+
function print_string(value, opts) {
|
52
|
+
var character_substitutions = {
|
53
|
+
'\b': '\\b',
|
54
|
+
'\t': '\\t',
|
55
|
+
'\n': '\\n',
|
56
|
+
'\f': '\\f',
|
57
|
+
'\r': '\\r',
|
58
|
+
'"' : '\\"',
|
59
|
+
'\\': '\\\\'
|
60
|
+
};
|
61
|
+
var r = /["\\\x00-\x1f\x7f-\x9f]/g;
|
62
|
+
|
63
|
+
var str = r.test(value)
|
64
|
+
? '"' + value.replace(r, function (a) {
|
65
|
+
var c = character_substitutions[a];
|
66
|
+
if (c) return c;
|
67
|
+
c = a.charCodeAt();
|
68
|
+
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
|
69
|
+
}) + '"'
|
70
|
+
: '"' + value + '"';
|
71
|
+
if (str.length > opts.max_string)
|
72
|
+
return str.slice(0, opts.max_string + 1) + '..."';
|
73
|
+
else
|
74
|
+
return str;
|
75
|
+
}
|
76
|
+
|
77
|
+
$.print = function(obj, options) {
|
78
|
+
var opts = $.extend({}, { max_array: 10, max_string: 100 }, options);
|
79
|
+
|
80
|
+
if (typeof obj == 'undefined')
|
81
|
+
return "undefined";
|
82
|
+
else if (typeof obj == 'boolean')
|
83
|
+
return obj.toString();
|
84
|
+
else if (!obj && typeof obj == 'number')
|
85
|
+
return 'NaN';
|
86
|
+
else if (!obj)
|
87
|
+
return "null";
|
88
|
+
else if (typeof obj == 'string')
|
89
|
+
return print_string(obj, opts);
|
90
|
+
else if (obj instanceof RegExp)
|
91
|
+
return obj.toString();
|
92
|
+
else if (typeof obj == 'function' || obj instanceof Function)
|
93
|
+
return obj.toString().match(/^([^)]*\))/)[1];
|
94
|
+
else if (obj instanceof Array)
|
95
|
+
return print_array(obj, opts);
|
96
|
+
else if (obj.nodeType)
|
97
|
+
return print_element(obj);
|
98
|
+
else if (obj instanceof jQuery)
|
99
|
+
return "$(" + $.print(obj.get()) + ")";
|
100
|
+
else if (obj instanceof Error)
|
101
|
+
return print_object(obj, $.extend({}, options, { max_string: 200 }));
|
102
|
+
else if (obj instanceof Object)
|
103
|
+
return print_object(obj, opts);
|
104
|
+
else
|
105
|
+
return obj.toString().replace(/\n\s*/g, '');
|
106
|
+
}
|
107
|
+
|
108
|
+
})(jQuery);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
(function() {
|
2
|
+
Screw.Assets = {};
|
3
|
+
Screw.Assets.use_cache_buster = false; // TODO: NS/CTI - make this configurable from the UI.
|
4
|
+
var required_paths = [];
|
5
|
+
var included_stylesheets = {};
|
6
|
+
var cache_buster = parseInt(new Date().getTime()/(1*1000));
|
7
|
+
|
8
|
+
Screw.Assets.require = function(javascript_path, onload) {
|
9
|
+
if(!required_paths[javascript_path]) {
|
10
|
+
var full_path = javascript_path + ".js";
|
11
|
+
if (Screw.Assets.use_cache_buster) {
|
12
|
+
full_path += '?' + cache_buster;
|
13
|
+
}
|
14
|
+
document.write("<script src='" + full_path + "' type='text/javascript'></script>");
|
15
|
+
if(onload) {
|
16
|
+
var scripts = document.getElementsByTagName('script');
|
17
|
+
scripts[scripts.length-1].onload = onload;
|
18
|
+
}
|
19
|
+
required_paths[javascript_path] = true;
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
Screw.Assets.stylesheet = function(stylesheet_path) {
|
24
|
+
if(!included_stylesheets[stylesheet_path]) {
|
25
|
+
var full_path = stylesheet_path + ".css";
|
26
|
+
if(Screw.Assets.use_cache_buster) {
|
27
|
+
full_path += '?' + cache_buster;
|
28
|
+
}
|
29
|
+
document.write("<link rel='stylesheet' type='text/css' href='" + full_path + "' />");
|
30
|
+
included_stylesheets[stylesheet_path] = true;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
window.require = Screw.Assets.require;
|
35
|
+
window.stylesheet = Screw.Assets.stylesheet;
|
36
|
+
})();
|
@@ -0,0 +1,91 @@
|
|
1
|
+
(function($) {
|
2
|
+
$(Screw).bind('loaded', function() {
|
3
|
+
$('.status').fn({
|
4
|
+
display: function() {
|
5
|
+
$(this).text(
|
6
|
+
$('.passed').length + $('.failed').length + ' test(s), ' + $('.failed').length + ' failure(s)'
|
7
|
+
);
|
8
|
+
}
|
9
|
+
});
|
10
|
+
|
11
|
+
$('.describe').fn({
|
12
|
+
parent: function() {
|
13
|
+
return $(this).parent('.describes').parent('.describe');
|
14
|
+
},
|
15
|
+
|
16
|
+
run_befores: function() {
|
17
|
+
$(this).fn('parent').fn('run_befores');
|
18
|
+
$(this).children('.befores').children('.before').fn('run');
|
19
|
+
},
|
20
|
+
|
21
|
+
run_afters: function() {
|
22
|
+
$(this).fn('parent').fn('run_afters');
|
23
|
+
$(this).children('.afters').children('.after').fn('run');
|
24
|
+
},
|
25
|
+
|
26
|
+
enqueue: function() {
|
27
|
+
$(this).children('.its').children('.it').fn('enqueue');
|
28
|
+
$(this).children('.describes').children('.describe').fn('enqueue');
|
29
|
+
},
|
30
|
+
|
31
|
+
selector: function() {
|
32
|
+
return $(this).fn('parent').fn('selector')
|
33
|
+
+ ' > .describes > .describe:eq(' + $(this).parent('.describes').children('.describe').index(this) + ')';
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
$('body > .describe').fn({
|
38
|
+
selector: function() { return 'body > .describe' }
|
39
|
+
});
|
40
|
+
|
41
|
+
$('.it').fn({
|
42
|
+
parent: function() {
|
43
|
+
return $(this).parent('.its').parent('.describe');
|
44
|
+
},
|
45
|
+
|
46
|
+
run: function() {
|
47
|
+
try {
|
48
|
+
try {
|
49
|
+
$(this).fn('parent').fn('run_befores');
|
50
|
+
$(this).data('screwunit.run')();
|
51
|
+
} finally {
|
52
|
+
$(this).fn('parent').fn('run_afters');
|
53
|
+
}
|
54
|
+
$(this).trigger('passed');
|
55
|
+
} catch(e) {
|
56
|
+
$(this).trigger('failed', [e]);
|
57
|
+
}
|
58
|
+
},
|
59
|
+
|
60
|
+
enqueue: function() {
|
61
|
+
var self = $(this).trigger('enqueued');
|
62
|
+
$(Screw)
|
63
|
+
.queue(function() {
|
64
|
+
self.fn('run');
|
65
|
+
setTimeout(function() { $(Screw).dequeue() }, 0);
|
66
|
+
});
|
67
|
+
},
|
68
|
+
|
69
|
+
selector: function() {
|
70
|
+
return $(this).fn('parent').fn('selector')
|
71
|
+
+ ' > .its > .it:eq(' + $(this).parent('.its').children('.it').index(this) + ')';
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
$('.before').fn({
|
76
|
+
run: function() { $(this).data('screwunit.run')() }
|
77
|
+
});
|
78
|
+
|
79
|
+
$('.after').fn({
|
80
|
+
run: function() { $(this).data('screwunit.run')() }
|
81
|
+
});
|
82
|
+
|
83
|
+
$(Screw).trigger('before');
|
84
|
+
var to_run = unescape(location.search.slice(1)) || 'body > .describe > .describes > .describe';
|
85
|
+
$(to_run)
|
86
|
+
.focus()
|
87
|
+
.eq(0).trigger('scroll').end()
|
88
|
+
.fn('enqueue');
|
89
|
+
$(Screw).queue(function() { $(Screw).trigger('after') });
|
90
|
+
})
|
91
|
+
})(jQuery);
|
@@ -0,0 +1,80 @@
|
|
1
|
+
var Screw = (function($) {
|
2
|
+
var screw = {
|
3
|
+
Unit: function(fn) {
|
4
|
+
var contents = fn.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];
|
5
|
+
var fn = new Function("matchers", "specifications",
|
6
|
+
"with (specifications) { with (matchers) { " + contents + " } }"
|
7
|
+
);
|
8
|
+
|
9
|
+
$(Screw).queue(function() {
|
10
|
+
Screw.Specifications.context.push($('body > .describe'));
|
11
|
+
fn.call(this, Screw.Matchers, Screw.Specifications);
|
12
|
+
Screw.Specifications.context.pop();
|
13
|
+
$(this).dequeue();
|
14
|
+
});
|
15
|
+
},
|
16
|
+
|
17
|
+
Specifications: {
|
18
|
+
context: [],
|
19
|
+
|
20
|
+
describe: function(name, fn) {
|
21
|
+
var describe = $('<li class="describe">')
|
22
|
+
.append($('<h1>').text(name))
|
23
|
+
.append('<ol class="befores">')
|
24
|
+
.append('<ul class="its">')
|
25
|
+
.append('<ul class="describes">')
|
26
|
+
.append('<ol class="afters">');
|
27
|
+
|
28
|
+
this.context.push(describe);
|
29
|
+
fn.call();
|
30
|
+
this.context.pop();
|
31
|
+
|
32
|
+
this.context[this.context.length-1]
|
33
|
+
.children('.describes')
|
34
|
+
.append(describe);
|
35
|
+
},
|
36
|
+
|
37
|
+
it: function(name, fn) {
|
38
|
+
var it = $('<li class="it">')
|
39
|
+
.append($('<h2>').text(name))
|
40
|
+
.data('screwunit.run', fn);
|
41
|
+
|
42
|
+
this.context[this.context.length-1]
|
43
|
+
.children('.its')
|
44
|
+
.append(it);
|
45
|
+
},
|
46
|
+
|
47
|
+
before: function(fn) {
|
48
|
+
var before = $('<li class="before">')
|
49
|
+
.data('screwunit.run', fn);
|
50
|
+
|
51
|
+
this.context[this.context.length-1]
|
52
|
+
.children('.befores')
|
53
|
+
.append(before);
|
54
|
+
},
|
55
|
+
|
56
|
+
after: function(fn) {
|
57
|
+
var after = $('<li class="after">')
|
58
|
+
.data('screwunit.run', fn);
|
59
|
+
|
60
|
+
this.context[this.context.length-1]
|
61
|
+
.children('.afters')
|
62
|
+
.append(after);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
$(screw).queue(function() { $(screw).trigger('loading') });
|
68
|
+
$(function() {
|
69
|
+
$('<div class="describe">')
|
70
|
+
.append('<h3 class="status">')
|
71
|
+
.append('<ol class="befores">')
|
72
|
+
.append('<ul class="describes">')
|
73
|
+
.append('<ol class="afters">')
|
74
|
+
.appendTo('body');
|
75
|
+
|
76
|
+
$(screw).dequeue();
|
77
|
+
$(screw).trigger('loaded');
|
78
|
+
});
|
79
|
+
return screw;
|
80
|
+
})(jQuery);
|
@@ -0,0 +1,90 @@
|
|
1
|
+
html {
|
2
|
+
padding: 0.5em;
|
3
|
+
font-family: Georgia, serif;
|
4
|
+
background: #EDEBD5;
|
5
|
+
}
|
6
|
+
|
7
|
+
li {
|
8
|
+
list-style-type: none;
|
9
|
+
}
|
10
|
+
|
11
|
+
.focused {
|
12
|
+
background-color: #F4F2E4;
|
13
|
+
}
|
14
|
+
|
15
|
+
.focused * {
|
16
|
+
opacity: 1.0;
|
17
|
+
}
|
18
|
+
|
19
|
+
h1, h2, p {
|
20
|
+
opacity: 0.4;
|
21
|
+
}
|
22
|
+
|
23
|
+
.describes {
|
24
|
+
padding-left: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
.describes h1 {
|
28
|
+
font-size: 1.1em;
|
29
|
+
color: #877C21;
|
30
|
+
line-height: 1.8em;
|
31
|
+
margin: 0pt 0pt 0.6em;
|
32
|
+
border-bottom: 1px solid transparent;
|
33
|
+
}
|
34
|
+
|
35
|
+
.describes h1:hover {
|
36
|
+
cursor: pointer;
|
37
|
+
color: #000;
|
38
|
+
background-color: #F4F2E4;
|
39
|
+
border-bottom: 1px solid #9A8E51;
|
40
|
+
}
|
41
|
+
|
42
|
+
.describes .describe {
|
43
|
+
margin-left: 0.6em;
|
44
|
+
padding-left: 0.6em;
|
45
|
+
border: 1px dashed grey;
|
46
|
+
}
|
47
|
+
|
48
|
+
.describes .describe .its {}
|
49
|
+
|
50
|
+
.describes .describe .its .it {
|
51
|
+
list-style-type: lower-roman;
|
52
|
+
list-style-position: outside;
|
53
|
+
}
|
54
|
+
|
55
|
+
.describes .describe .its .it h2 {
|
56
|
+
font-weight: normal;
|
57
|
+
font-style: italic;
|
58
|
+
padding-left: 0.5em;
|
59
|
+
font-size: 1.0em;
|
60
|
+
color: #877C21;
|
61
|
+
line-height: 1.8em;
|
62
|
+
margin: 0 0 0.5em;
|
63
|
+
border-bottom: 1px solid transparent;
|
64
|
+
}
|
65
|
+
|
66
|
+
.describes .describe .its .it.enqueued h2 {
|
67
|
+
background-color: #CC6600;
|
68
|
+
color: white !important;
|
69
|
+
}
|
70
|
+
|
71
|
+
.describes .describe .its .it.passed h2 {
|
72
|
+
background-color: #5A753D;
|
73
|
+
color: white !important;
|
74
|
+
}
|
75
|
+
|
76
|
+
.describes .describe .its .it.failed h2 {
|
77
|
+
background-color: #993300;
|
78
|
+
color: white !important;
|
79
|
+
}
|
80
|
+
|
81
|
+
.describes .describe .its .it.failed p {
|
82
|
+
margin-left: 1em;
|
83
|
+
color: #993300;
|
84
|
+
}
|
85
|
+
|
86
|
+
.describes .describe .its .it h2:hover {
|
87
|
+
cursor: pointer;
|
88
|
+
color: #000 !important;
|
89
|
+
border-bottom: 1px solid #9A8E51;
|
90
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
(function($) {
|
2
|
+
$(Screw)
|
3
|
+
.bind('loaded', function() {
|
4
|
+
$('.describe, .it')
|
5
|
+
.click(function() {
|
6
|
+
document.location = location.href.split('?')[0] + '?' + $(this).fn('selector');
|
7
|
+
return false;
|
8
|
+
})
|
9
|
+
.focus(function() {
|
10
|
+
return $(this).addClass('focused');
|
11
|
+
})
|
12
|
+
.bind('scroll', function() {
|
13
|
+
document.body.scrollTop = $(this).offset().top;
|
14
|
+
});
|
15
|
+
|
16
|
+
$('.it')
|
17
|
+
.bind('enqueued', function() {
|
18
|
+
$(this).addClass('enqueued');
|
19
|
+
})
|
20
|
+
.bind('running', function() {
|
21
|
+
$(this).addClass('running');
|
22
|
+
})
|
23
|
+
.bind('passed', function() {
|
24
|
+
$(this).addClass('passed');
|
25
|
+
})
|
26
|
+
.bind('failed', function(e, reason) {
|
27
|
+
$(this)
|
28
|
+
.addClass('failed')
|
29
|
+
.append($('<p class="error">').text(reason.toString()));
|
30
|
+
if (reason.fileName || reason.lineNumber) {
|
31
|
+
$(this)
|
32
|
+
.append($('<p class="error">').text(reason.fileName + " : " + reason.lineNumber));
|
33
|
+
}
|
34
|
+
})
|
35
|
+
})
|
36
|
+
.bind('before', function() {
|
37
|
+
$('.status').text('Running...');
|
38
|
+
})
|
39
|
+
.bind('after', function() {
|
40
|
+
$('.status').fn('display')
|
41
|
+
})
|
42
|
+
})(jQuery);
|
@@ -0,0 +1,145 @@
|
|
1
|
+
Screw.Matchers = (function($) {
|
2
|
+
return matchers = {
|
3
|
+
expect: function(actual) {
|
4
|
+
return {
|
5
|
+
to: function(matcher, expected, not) {
|
6
|
+
var matched = matcher.match(expected, actual);
|
7
|
+
if (not ? matched : !matched) {
|
8
|
+
throw(matcher.failure_message(expected, actual, not));
|
9
|
+
}
|
10
|
+
},
|
11
|
+
|
12
|
+
to_not: function(matcher, expected) {
|
13
|
+
this.to(matcher, expected, true);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
},
|
17
|
+
|
18
|
+
equal: {
|
19
|
+
match: function(expected, actual) {
|
20
|
+
if (expected instanceof Array) {
|
21
|
+
for (var i = 0; i < actual.length; i++)
|
22
|
+
if (!Screw.Matchers.equal.match(expected[i], actual[i])) return false;
|
23
|
+
return actual.length == expected.length;
|
24
|
+
} else if (expected instanceof Object) {
|
25
|
+
for (var key in expected)
|
26
|
+
if (expected[key] != actual[key]) return false;
|
27
|
+
for (var key in actual)
|
28
|
+
if (actual[key] != expected[key]) return false;
|
29
|
+
return true;
|
30
|
+
} else {
|
31
|
+
return expected == actual;
|
32
|
+
}
|
33
|
+
},
|
34
|
+
|
35
|
+
failure_message: function(expected, actual, not) {
|
36
|
+
return 'expected ' + $.print(actual) + (not ? ' to not equal ' : ' to equal ') + $.print(expected);
|
37
|
+
}
|
38
|
+
},
|
39
|
+
|
40
|
+
match: {
|
41
|
+
match: function(expected, actual) {
|
42
|
+
if (expected.constructor == RegExp)
|
43
|
+
return expected.exec(actual.toString());
|
44
|
+
else
|
45
|
+
return actual.indexOf(expected) > -1;
|
46
|
+
},
|
47
|
+
|
48
|
+
failure_message: function(expected, actual, not) {
|
49
|
+
return 'expected ' + $.print(actual) + (not ? ' to not match ' : ' to match ') + $.print(expected);
|
50
|
+
}
|
51
|
+
},
|
52
|
+
|
53
|
+
be_empty: {
|
54
|
+
match: function(expected, actual) {
|
55
|
+
if (actual.length == undefined) throw(actual.toString() + " does not respond to length");
|
56
|
+
|
57
|
+
return actual.length == 0;
|
58
|
+
},
|
59
|
+
|
60
|
+
failure_message: function(expected, actual, not) {
|
61
|
+
return 'expected ' + $.print(actual) + (not ? ' to not be empty' : ' to be empty');
|
62
|
+
}
|
63
|
+
},
|
64
|
+
|
65
|
+
have_length: {
|
66
|
+
match: function(expected, actual) {
|
67
|
+
if (actual.length == undefined) throw(actual.toString() + " does not respond to length");
|
68
|
+
|
69
|
+
return actual.length == expected;
|
70
|
+
},
|
71
|
+
|
72
|
+
failure_message: function(expected, actual, not) {
|
73
|
+
return 'expected ' + $.print(actual) + (not ? ' to not' : ' to') + ' have length ' + expected;
|
74
|
+
}
|
75
|
+
},
|
76
|
+
|
77
|
+
be_null: {
|
78
|
+
match: function(expected, actual) {
|
79
|
+
return actual == null;
|
80
|
+
},
|
81
|
+
|
82
|
+
failure_message: function(expected, actual, not) {
|
83
|
+
return 'expected ' + $.print(actual) + (not ? ' to not be null' : ' to be null');
|
84
|
+
}
|
85
|
+
},
|
86
|
+
|
87
|
+
be_undefined: {
|
88
|
+
match: function(expected, actual) {
|
89
|
+
return actual == undefined;
|
90
|
+
},
|
91
|
+
|
92
|
+
failure_message: function(expected, actual, not) {
|
93
|
+
return 'expected ' + $.print(actual) + (not ? ' to not be undefined' : ' to be undefined');
|
94
|
+
}
|
95
|
+
},
|
96
|
+
|
97
|
+
be_true: {
|
98
|
+
match: function(expected, actual) {
|
99
|
+
return actual;
|
100
|
+
},
|
101
|
+
|
102
|
+
failure_message: function(expected, actual, not) {
|
103
|
+
return 'expected ' + $.print(actual) + (not ? ' to not be true' : ' to be true');
|
104
|
+
}
|
105
|
+
},
|
106
|
+
|
107
|
+
be_false: {
|
108
|
+
match: function(expected, actual) {
|
109
|
+
return !actual;
|
110
|
+
},
|
111
|
+
|
112
|
+
failure_message: function(expected, actual, not) {
|
113
|
+
return 'expected ' + $.print(actual) + (not ? ' to not be false' : ' to be false');
|
114
|
+
}
|
115
|
+
},
|
116
|
+
|
117
|
+
match_selector: {
|
118
|
+
match: function(expected, actual) {
|
119
|
+
if (!(actual instanceof jQuery)) {
|
120
|
+
throw expected.toString() + " must be an instance of jQuery to match against a selector"
|
121
|
+
}
|
122
|
+
|
123
|
+
return actual.is(expected);
|
124
|
+
},
|
125
|
+
|
126
|
+
failure_message: function(expected, actual, not) {
|
127
|
+
return 'expected ' + $.print(actual) + (not ? ' to not match selector ' : ' to match selector ') + expected;
|
128
|
+
}
|
129
|
+
},
|
130
|
+
|
131
|
+
contain_selector: {
|
132
|
+
match: function(expected, actual) {
|
133
|
+
if (!(actual instanceof jQuery)) {
|
134
|
+
throw expected.toString() + " must be an instance of jQuery to match against a selector"
|
135
|
+
}
|
136
|
+
|
137
|
+
return actual.find(expected).length > 0;
|
138
|
+
},
|
139
|
+
|
140
|
+
failure_message: function(expected, actual, not) {
|
141
|
+
return 'expected ' + $.print(actual) + (not ? ' to not contain selector ' : ' to contain selector ') + expected;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
})(jQuery);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
(function($) {
|
2
|
+
var ajax = $.ajax;
|
3
|
+
$(Screw).bind('after', function() {
|
4
|
+
var error_text = $(".error").map(function(i, element) {
|
5
|
+
return element.innerHTML;
|
6
|
+
}).get().join("\n");
|
7
|
+
|
8
|
+
var suite_id;
|
9
|
+
if(top.runOptions) {
|
10
|
+
suite_id = top.runOptions.getSessionId();
|
11
|
+
} else {
|
12
|
+
suite_id = 'user';
|
13
|
+
}
|
14
|
+
|
15
|
+
ajax({
|
16
|
+
type: "POST",
|
17
|
+
url: '/suites/' + suite_id + '/finish',
|
18
|
+
data: {"text": error_text}
|
19
|
+
});
|
20
|
+
});
|
21
|
+
})(jQuery);
|