riojs 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +24 -0
- data/VERSION +1 -0
- data/bin/rio +5 -0
- data/generators/rio_app/USAGE +19 -0
- data/generators/rio_app/rio_app_generator.rb +40 -0
- data/generators/rio_app/templates/app.build +10 -0
- data/generators/rio_app/templates/app.css +0 -0
- data/generators/rio_app/templates/app.js +20 -0
- data/generators/rio_app/templates/app_view.html.erb +19 -0
- data/generators/rio_app/templates/fixture.js +4 -0
- data/generators/rio_app/templates/rio.html.erb +18 -0
- data/generators/rio_app/templates/rio_controller.rb +2 -0
- data/generators/rio_app/templates/spec.js +7 -0
- data/generators/rio_component/USAGE +13 -0
- data/generators/rio_component/rio_component_generator.rb +16 -0
- data/generators/rio_component/templates/component.css +0 -0
- data/generators/rio_component/templates/component.js +11 -0
- data/generators/rio_component/templates/fixture.js +3 -0
- data/generators/rio_component/templates/spec.js +6 -0
- data/generators/rio_model/USAGE +12 -0
- data/generators/rio_model/rio_model_generator.rb +21 -0
- data/generators/rio_model/templates/fixture.js +3 -0
- data/generators/rio_model/templates/model.js +9 -0
- data/generators/rio_model/templates/spec.js +6 -0
- data/generators/rio_page/USAGE +14 -0
- data/generators/rio_page/rio_page_generator.rb +16 -0
- data/generators/rio_page/templates/fixture.js +3 -0
- data/generators/rio_page/templates/page.css +12 -0
- data/generators/rio_page/templates/page.js +12 -0
- data/generators/rio_page/templates/page.jst +64 -0
- data/generators/rio_page/templates/spec.js +6 -0
- data/generators/rio_resource/USAGE +20 -0
- data/generators/rio_resource/rio_resource_generator.rb +10 -0
- data/generators/rio_resource/templates/controller.rb +3 -0
- data/init.rb +4 -0
- data/install/config/juggernaut_hosts.yml +18 -0
- data/install/lib/tasks/rio.rake +1 -0
- data/install/script/rio_server +37 -0
- data/lib/rio/autospec.rb +86 -0
- data/lib/rio/install.rb +90 -0
- data/lib/rio/juggernaut.rb +212 -0
- data/lib/rio/path.rb +3 -0
- data/lib/rio/rio_compressor.rb +219 -0
- data/lib/rio/rio_file_controller.rb +16 -0
- data/lib/rio/rio_on_rails.rb +586 -0
- data/lib/rio/rio_proxy_controller.rb +60 -0
- data/lib/rio/rio_push_controller.rb +48 -0
- data/lib/rio/rio_routes.rb +24 -0
- data/lib/rio/rio_spec_controller.rb +70 -0
- data/lib/riojs.rb +14 -0
- data/lib/tasks/rio.rb +63 -0
- data/public/images/background-chiffon.png +0 -0
- data/public/images/button-gradient-overlay-down.png +0 -0
- data/public/images/button-gradient-overlay.png +0 -0
- data/public/images/icons/add.png +0 -0
- data/public/images/icons/error-big.png +0 -0
- data/public/images/icons/warning-big.png +0 -0
- data/public/images/rio-logo-big.png +0 -0
- data/public/images/rio-logo.png +0 -0
- data/public/images/splitter-handle-horizontal.png +0 -0
- data/public/images/splitter-handle-vertical.png +0 -0
- data/public/images/tab-bar-gradient-overlay.png +0 -0
- data/public/images/title-gradient-overlay.png +0 -0
- data/public/images/trash.gif +0 -0
- data/public/javascripts/components/accordion.js +144 -0
- data/public/javascripts/components/alert_box.js +59 -0
- data/public/javascripts/components/base.js +47 -0
- data/public/javascripts/components/box.js +63 -0
- data/public/javascripts/components/button.js +98 -0
- data/public/javascripts/components/checkbox.js +44 -0
- data/public/javascripts/components/container.js +265 -0
- data/public/javascripts/components/grid_view.js +107 -0
- data/public/javascripts/components/image.js +19 -0
- data/public/javascripts/components/input.js +171 -0
- data/public/javascripts/components/label.js +15 -0
- data/public/javascripts/components/lightbox.js +160 -0
- data/public/javascripts/components/link.js +43 -0
- data/public/javascripts/components/list_item.js +44 -0
- data/public/javascripts/components/list_view.js +192 -0
- data/public/javascripts/components/marquee.js +131 -0
- data/public/javascripts/components/menu.js +89 -0
- data/public/javascripts/components/notification.js +75 -0
- data/public/javascripts/components/overlay.js +134 -0
- data/public/javascripts/components/panel.js +146 -0
- data/public/javascripts/components/radio.js +46 -0
- data/public/javascripts/components/splitter.js +65 -0
- data/public/javascripts/components/tab_bar.js +64 -0
- data/public/javascripts/components/tab_panel.js +57 -0
- data/public/javascripts/components/textarea.js +223 -0
- data/public/javascripts/components/toggle_button.js +22 -0
- data/public/javascripts/components/tooltip.js +80 -0
- data/public/javascripts/lib/application.js +482 -0
- data/public/javascripts/lib/attr.js +760 -0
- data/public/javascripts/lib/benchmark.js +235 -0
- data/public/javascripts/lib/blank.html +39 -0
- data/public/javascripts/lib/boot.js +300 -0
- data/public/javascripts/lib/clipboard.js +96 -0
- data/public/javascripts/lib/collection_entity.js +46 -0
- data/public/javascripts/lib/component.js +129 -0
- data/public/javascripts/lib/console.js +75 -0
- data/public/javascripts/lib/console/apps/console.build +43 -0
- data/public/javascripts/lib/console/apps/console.js +28 -0
- data/public/javascripts/lib/console/blank.html +39 -0
- data/public/javascripts/lib/console/components/benchmark.js +196 -0
- data/public/javascripts/lib/console/components/console.js +352 -0
- data/public/javascripts/lib/console/components/dependencies_list.js +17 -0
- data/public/javascripts/lib/console/components/docs.js +66 -0
- data/public/javascripts/lib/console/components/playground.js +30 -0
- data/public/javascripts/lib/console/console.html +27 -0
- data/public/javascripts/lib/console/console_commands.js +287 -0
- data/public/javascripts/lib/console/console_commands.js.rej +21 -0
- data/public/javascripts/lib/console/console_mixin.js +22 -0
- data/public/javascripts/lib/console/docs/files.html +579 -0
- data/public/javascripts/lib/console/docs/index.html +323 -0
- data/public/javascripts/lib/console/docs/symbols/Object.html +291 -0
- data/public/javascripts/lib/console/docs/symbols/_global_.html +413 -0
- data/public/javascripts/lib/console/docs/symbols/rio.AIM.html +490 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Application.html +841 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Attr.html +1075 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Binding.html +272 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Component.html +419 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Cookie.html +543 -0
- data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask#initialize.html +270 -0
- data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask.html +391 -0
- data/public/javascripts/lib/console/docs/symbols/rio.JsTemplate.html +271 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Juggernaut.html +329 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Model.html +822 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Page.html +383 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Template.html +328 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Utils.html +617 -0
- data/public/javascripts/lib/console/docs/symbols/rio.html +506 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_components_base.js.html +54 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_application.js.html +490 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_attr.js.html +768 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_boot.js.html +308 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_clipboard.js.html +103 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_collection_entity.js.html +53 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_component.js.html +137 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_cookie.js.html +81 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_delayed_task.js.html +68 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_file.js.html +80 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_flash_detect.js.html +129 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_form.js.html +95 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_id.js.html +50 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_inflector.js.html +167 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_js_template.js.html +283 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_juggernaut.js.html +303 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_key_map.js.html +68 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_layout_manager.js.html +175 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_log.js.html +17 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_model.js.html +1074 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_page.js.html +246 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_parameters.js.html +66 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_protohack.js.html +305 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_push.js.html +12 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_rsh.js.html +659 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_swfobject.js.html +12 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_tag.js.html +60 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_template.js.html +64 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_theme.js.html +105 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_undo.js.html +142 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_utils.js.html +87 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_yaml.js.html +88 -0
- data/public/javascripts/lib/console/file-small.png +0 -0
- data/public/javascripts/lib/console/green-circle.png +0 -0
- data/public/javascripts/lib/console/loading.gif +0 -0
- data/public/javascripts/lib/console/pages/console_page.js +149 -0
- data/public/javascripts/lib/console/pages/console_page.jst +27 -0
- data/public/javascripts/lib/console/red-circle.png +0 -0
- data/public/javascripts/lib/cookie.js +74 -0
- data/public/javascripts/lib/delayed_task.js +61 -0
- data/public/javascripts/lib/dependencies.js +76 -0
- data/public/javascripts/lib/environment.js +30 -0
- data/public/javascripts/lib/event.simulate.js +137 -0
- data/public/javascripts/lib/expressinstall.swf +0 -0
- data/public/javascripts/lib/file.js +72 -0
- data/public/javascripts/lib/flash_detect.js +122 -0
- data/public/javascripts/lib/flashembed.min.js +16 -0
- data/public/javascripts/lib/form.js +88 -0
- data/public/javascripts/lib/id.js +43 -0
- data/public/javascripts/lib/inflector.js +160 -0
- data/public/javascripts/lib/instrumenter.js +106 -0
- data/public/javascripts/lib/js_template.js +275 -0
- data/public/javascripts/lib/jslint.js +4950 -0
- data/public/javascripts/lib/juggernaut.js +295 -0
- data/public/javascripts/lib/juggernaut.swf +0 -0
- data/public/javascripts/lib/key_map.js +60 -0
- data/public/javascripts/lib/layout_manager.js +167 -0
- data/public/javascripts/lib/model.js +1067 -0
- data/public/javascripts/lib/page.js +238 -0
- data/public/javascripts/lib/parameters.js +59 -0
- data/public/javascripts/lib/png_fix.js +75 -0
- data/public/javascripts/lib/protohack.js +297 -0
- data/public/javascripts/lib/push.js +5 -0
- data/public/javascripts/lib/rio.build +28 -0
- data/public/javascripts/lib/rio_development.build +5 -0
- data/public/javascripts/lib/rio_lint.js +66 -0
- data/public/javascripts/lib/rsh.js +651 -0
- data/public/javascripts/lib/spec.js +545 -0
- data/public/javascripts/lib/spec_runner.js +242 -0
- data/public/javascripts/lib/swfobject.js +5 -0
- data/public/javascripts/lib/tag.js +52 -0
- data/public/javascripts/lib/undo.js +134 -0
- data/public/javascripts/lib/utils.js +80 -0
- data/public/javascripts/lib/yaml.js +80 -0
- data/public/javascripts/pages/playground_page.js +15 -0
- data/public/javascripts/prototype/builder.js +146 -0
- data/public/javascripts/prototype/controls.js +1004 -0
- data/public/javascripts/prototype/dragdrop.js +1030 -0
- data/public/javascripts/prototype/effects.js +1137 -0
- data/public/javascripts/prototype/prototype.js +4320 -0
- data/public/javascripts/prototype/slider.js +283 -0
- data/public/javascripts/prototype/sound.js +67 -0
- data/public/javascripts/specs/components/box_spec.js +6 -0
- data/public/javascripts/specs/components/checkbox_spec.js +26 -0
- data/public/javascripts/specs/components/container_spec.js +6 -0
- data/public/javascripts/specs/components/input_spec.js +71 -0
- data/public/javascripts/specs/components/panel_spec.js +6 -0
- data/public/javascripts/specs/components/radio_spec.js +40 -0
- data/public/javascripts/specs/fixtures/components/box.js +3 -0
- data/public/javascripts/specs/fixtures/components/checkbox.js +9 -0
- data/public/javascripts/specs/fixtures/components/container.js +3 -0
- data/public/javascripts/specs/fixtures/components/input.js +12 -0
- data/public/javascripts/specs/fixtures/components/menu.js +19 -0
- data/public/javascripts/specs/fixtures/components/menu_item.js +18 -0
- data/public/javascripts/specs/fixtures/components/radio.js +11 -0
- data/public/javascripts/specs/lib/application_spec.js +281 -0
- data/public/javascripts/specs/lib/attr_spec.js +1514 -0
- data/public/javascripts/specs/lib/benchmark_spec.js +361 -0
- data/public/javascripts/specs/lib/collection_entity_spec.js +131 -0
- data/public/javascripts/specs/lib/component_spec.js +86 -0
- data/public/javascripts/specs/lib/form_spec.js +171 -0
- data/public/javascripts/specs/lib/id_spec.js +21 -0
- data/public/javascripts/specs/lib/instrumenter_spec.js +5 -0
- data/public/javascripts/specs/lib/js_template_spec.js +131 -0
- data/public/javascripts/specs/lib/key_map_spec.js +227 -0
- data/public/javascripts/specs/lib/model_spec.js +2268 -0
- data/public/javascripts/specs/lib/parameters_spec.js +94 -0
- data/public/javascripts/specs/lib/spec_spec.js +943 -0
- data/public/javascripts/specs/lib/undo_spec.js +105 -0
- data/public/javascripts/specs/lib/yaml_spec.js +127 -0
- data/public/sounds/basso.wav +0 -0
- data/public/sounds/purr.wav +0 -0
- data/public/stylesheets/components/accordion.css +24 -0
- data/public/stylesheets/components/alert_box.css +35 -0
- data/public/stylesheets/components/box.css +0 -0
- data/public/stylesheets/components/button.css +39 -0
- data/public/stylesheets/components/checkbox.css +9 -0
- data/public/stylesheets/components/container.css +3 -0
- data/public/stylesheets/components/grid_view.css +52 -0
- data/public/stylesheets/components/input.css +10 -0
- data/public/stylesheets/components/label.css +3 -0
- data/public/stylesheets/components/lightbox.css +31 -0
- data/public/stylesheets/components/link.css +4 -0
- data/public/stylesheets/components/list_view.css +23 -0
- data/public/stylesheets/components/marquee.css +29 -0
- data/public/stylesheets/components/menu.css +34 -0
- data/public/stylesheets/components/notification.css +52 -0
- data/public/stylesheets/components/overlay.css +8 -0
- data/public/stylesheets/components/panel.css +36 -0
- data/public/stylesheets/components/radio.css +9 -0
- data/public/stylesheets/components/splitter.css +35 -0
- data/public/stylesheets/components/tab_bar.css +59 -0
- data/public/stylesheets/components/tab_panel.css +15 -0
- data/public/stylesheets/components/textarea.css +11 -0
- data/public/stylesheets/components/tooltip.css +10 -0
- data/public/stylesheets/console.css +151 -0
- data/public/stylesheets/css_reset.css +55 -0
- metadata +343 -0
@@ -0,0 +1,545 @@
|
|
1
|
+
rio.Spec = {
|
2
|
+
executeSpec: function(spec, stdout, env, context, specPage, doEval) {
|
3
|
+
try {
|
4
|
+
var stubManager = new env.rio.StubManager();
|
5
|
+
var mockManager = new env.rio.MockManager();
|
6
|
+
|
7
|
+
var stub = function(obj, method) {
|
8
|
+
return new env.rio.Stub(obj, method);
|
9
|
+
};
|
10
|
+
var stubs = [
|
11
|
+
stub(env, "specPage").withValue(specPage),
|
12
|
+
stub(env, "describe").withValue(
|
13
|
+
env.rio.Spec.describe.curry(env.rio.Spec, stdout, [], [], context, env.specPage, stubManager, mockManager)
|
14
|
+
),
|
15
|
+
stub(env, "stub").withValue(stubManager.stub.bind(stubManager)),
|
16
|
+
stub(env, "pending").withValue("PENDING"),
|
17
|
+
stub(env, "fail").withValue(
|
18
|
+
function(msg) {
|
19
|
+
throw msg;
|
20
|
+
}
|
21
|
+
),
|
22
|
+
stub(env, "insertComponent").withValue(
|
23
|
+
env.specPage.addComponent.bind(env.specPage)
|
24
|
+
),
|
25
|
+
stub(env.Function.prototype, "active").withValue(
|
26
|
+
function() {
|
27
|
+
this._activeSpec = true;
|
28
|
+
return this;
|
29
|
+
}
|
30
|
+
),
|
31
|
+
stub(Function.prototype, "active").withValue(
|
32
|
+
function() {
|
33
|
+
this._activeSpec = true;
|
34
|
+
return this;
|
35
|
+
}
|
36
|
+
),
|
37
|
+
stub(env, "shouldBeDefined").withValue(
|
38
|
+
function(val) {
|
39
|
+
rio.Assertions.shouldNot(val == undefined, "expected '" + val + "' to be defined.");
|
40
|
+
}
|
41
|
+
),
|
42
|
+
stub(env, "shouldBeUndefined").withValue(
|
43
|
+
function(val) {
|
44
|
+
rio.Assertions.should(val == undefined, "expected '" + val + "' to be undefined.");
|
45
|
+
}
|
46
|
+
),
|
47
|
+
stub(env, "shouldEqual").withValue(
|
48
|
+
function(val1, val2) {
|
49
|
+
rio.Assertions.should(val1 == val2, "expected '" + val1 + "' to equal '" + val2 + "'");
|
50
|
+
}
|
51
|
+
),
|
52
|
+
stub(env.rio, "mockManager").withValue(mockManager),
|
53
|
+
stub(rio, "mockManager").withValue(mockManager)
|
54
|
+
];
|
55
|
+
|
56
|
+
var instrumentModel = function(model) {
|
57
|
+
stubs.push(stub(model, "_idCache").withValue({}));
|
58
|
+
stubs.push(stub(model, "_identityCache").withValue({}));
|
59
|
+
stubs.push(stub(model, "_collectionEntities").withValue({}));
|
60
|
+
stubs.push(stub(model, "_transaction").withValue([]));
|
61
|
+
stubs.push(stub(model, "_transactionQueued").withValue(false));
|
62
|
+
stubs.push(stub(model, "__transactionInProgress").withValue(false));
|
63
|
+
stubs.push(stub(model, "prepareTransaction").withValue(function() {
|
64
|
+
this.executeTransaction(rio.Undo.isProcessingUndo(), rio.Undo.isProcessingRedo());
|
65
|
+
}.bind(model)));
|
66
|
+
|
67
|
+
var newInitialize = model.prototype.initialize.wrap(function(proceed) {
|
68
|
+
this.__example = true;
|
69
|
+
proceed.apply(this, $A(arguments).slice(1));
|
70
|
+
});
|
71
|
+
stubs.push(stub(model.prototype, "initialize").withValue(newInitialize));
|
72
|
+
|
73
|
+
var newExample = model.example.wrap(function(proceed, exampleName) {
|
74
|
+
var json = this._examples[exampleName];
|
75
|
+
if (json && this.id) {
|
76
|
+
var id = json.id;
|
77
|
+
var fromCache = this.getFromCache(this.id(id));
|
78
|
+
if (fromCache) {
|
79
|
+
return fromCache;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return proceed.apply(this, $A(arguments).slice(1));
|
83
|
+
});
|
84
|
+
stubs.push(stub(model, "example").withValue(newExample))
|
85
|
+
};
|
86
|
+
for (modelName in env.rio.models) {
|
87
|
+
instrumentModel(env.rio.models[modelName]);
|
88
|
+
}
|
89
|
+
stubs.push(stub(env, "instrumentModel").withValue(instrumentModel));
|
90
|
+
|
91
|
+
var newRequest = env.Ajax.Request.prototype.request.wrap(function(proceed, url) {
|
92
|
+
var resourceUrl = url.match(/^(\/[^\/]*).*$/)[1];
|
93
|
+
var model = Object.values(env.rio.models).detect(function(m) {
|
94
|
+
return m.url && (m.url() == resourceUrl);
|
95
|
+
});
|
96
|
+
|
97
|
+
if (model) {
|
98
|
+
if (this.options.method == "delete") {
|
99
|
+
this.options.onSuccess({});
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
if (this.options.method == "put") {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
|
106
|
+
var id = url.match(/^\/[^\/]*\/(.*)$/);
|
107
|
+
|
108
|
+
var jsonFromParams = function(json) {
|
109
|
+
if (env.rio.environment.includeRootInJson) {
|
110
|
+
var newJSON = {};
|
111
|
+
newJSON[model.NAME.underscore()] = json;
|
112
|
+
json = newJSON;
|
113
|
+
}
|
114
|
+
return json;
|
115
|
+
};
|
116
|
+
|
117
|
+
var json;
|
118
|
+
if (id) {
|
119
|
+
if (!id[1].isNumeric()) {
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
id = id[1];
|
123
|
+
var foundName = Object.keys(model._examples).detect(function(exampleName) {
|
124
|
+
var exampleJson = model._examples[exampleName];
|
125
|
+
return exampleJson.id == id;
|
126
|
+
});
|
127
|
+
if (!foundName) {
|
128
|
+
(this.options.onFailure || Prototype.emptyFunction)();
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
json = jsonFromParams(model.exampleParams(foundName));
|
132
|
+
} else if (this.options.method == "get") {
|
133
|
+
var parameters = this.options.parameters.conditions.evalJSON();
|
134
|
+
|
135
|
+
json = Object.keys(model._examples).select(function(exampleName) {
|
136
|
+
var exampleJson = model.exampleParams(exampleName);
|
137
|
+
|
138
|
+
return Object.keys(parameters).all(function(parameter) {
|
139
|
+
var val = parameters[parameter];
|
140
|
+
var jsonVal = exampleJson[parameter.underscore()] || exampleJson[parameter.camelize()];
|
141
|
+
if (val && val.not) {
|
142
|
+
return jsonVal != val.not;
|
143
|
+
} else {
|
144
|
+
return jsonVal == val;
|
145
|
+
}
|
146
|
+
});
|
147
|
+
|
148
|
+
}).map(function(exampleName) {
|
149
|
+
var exampleJson = model.exampleParams(exampleName);
|
150
|
+
var exampleId = exampleJson.id;
|
151
|
+
|
152
|
+
return jsonFromParams(exampleJson);
|
153
|
+
});
|
154
|
+
} else {
|
155
|
+
/*
|
156
|
+
This is a very limited handling of 'POST' requests.
|
157
|
+
|
158
|
+
-It doesn't handle transactions
|
159
|
+
-It has no tests
|
160
|
+
*/
|
161
|
+
var newId = Object.values(model._identityCache).min() - 1;
|
162
|
+
newId = isNaN(newId) ? -1 : newId;
|
163
|
+
json = jsonFromParams({ id: newId });
|
164
|
+
}
|
165
|
+
this.options.onSuccess({ responseJSON: json, status: 200 });
|
166
|
+
} else {
|
167
|
+
return proceed(url);
|
168
|
+
}
|
169
|
+
});
|
170
|
+
stubs.push(stub(env.Ajax.Request.prototype, "request").withValue(newRequest));
|
171
|
+
|
172
|
+
stubs.push(stub(env, "preloadFixtures").withValue(function() {
|
173
|
+
var callbackQueue = [];
|
174
|
+
var requestStubMethod = env.Ajax.Request.prototype.request.wrap(function(proceed) {
|
175
|
+
var oldOnSuccess = this.options.onSuccess;
|
176
|
+
this.options.onSuccess = function() {
|
177
|
+
var successArgs = arguments;
|
178
|
+
callbackQueue.push(function() {
|
179
|
+
oldOnSuccess.apply(this, successArgs);
|
180
|
+
});
|
181
|
+
};
|
182
|
+
return proceed.apply(this, $A(arguments).slice(1));
|
183
|
+
});
|
184
|
+
var requestStub = stub(Ajax.Request.prototype, "request").withValue(requestStubMethod);
|
185
|
+
for (modelName in env.rio.models) {
|
186
|
+
var model = env.rio.models[modelName];
|
187
|
+
Object.keys(model._examples).each(function(exampleName) {
|
188
|
+
model.example(exampleName);
|
189
|
+
});
|
190
|
+
}
|
191
|
+
callbackQueue.each(function(callback) { callback(); });
|
192
|
+
requestStub.release();
|
193
|
+
}));
|
194
|
+
|
195
|
+
stubs.push(stub(env, "render").withValue(function(page) {
|
196
|
+
env.rio.app.clearPage();
|
197
|
+
env.Element.body().insert(page.html());
|
198
|
+
page.render();
|
199
|
+
env.rio.app.setCurrentPage(page);
|
200
|
+
}));
|
201
|
+
|
202
|
+
doEval(spec);
|
203
|
+
} catch(e) {
|
204
|
+
stdout(e, "warningLogItem");
|
205
|
+
// Ignore spec parsing errors.
|
206
|
+
} finally {
|
207
|
+
stubs.invoke("release");
|
208
|
+
}
|
209
|
+
},
|
210
|
+
|
211
|
+
describe: function(that, stdout, befores, afters, context, specPage, stubManager, mockManager, cls, content) {
|
212
|
+
try {
|
213
|
+
var findActiveSpec = function(desc) {
|
214
|
+
var activeSpec;
|
215
|
+
Object.keys(desc).each(function(k) {
|
216
|
+
var v = desc[k];
|
217
|
+
if (v == "PENDING") { return; }
|
218
|
+
var vActiveSpec = (v._activeSpec && k) || (!Object.isFunction(v) && findActiveSpec(v));
|
219
|
+
if (vActiveSpec) {
|
220
|
+
activeSpec = vActiveSpec;
|
221
|
+
}
|
222
|
+
});
|
223
|
+
return activeSpec;
|
224
|
+
};
|
225
|
+
var activeSpec = findActiveSpec(content);
|
226
|
+
if (activeSpec) {
|
227
|
+
|
228
|
+
var removeNonActiveSpecs = function(desc) {
|
229
|
+
Object.keys(desc).each(function(k) {
|
230
|
+
var v = desc[k];
|
231
|
+
if (v == "PENDING") {
|
232
|
+
delete desc[k];
|
233
|
+
} else if (Object.isFunction(v)) {
|
234
|
+
if (!v._activeSpec && !(k == "beforeEach" || k == "afterEach")) {
|
235
|
+
delete desc[k];
|
236
|
+
}
|
237
|
+
} else {
|
238
|
+
removeNonActiveSpecs(v);
|
239
|
+
}
|
240
|
+
});
|
241
|
+
};
|
242
|
+
|
243
|
+
removeNonActiveSpecs(content);
|
244
|
+
}
|
245
|
+
} catch(e) {
|
246
|
+
stdout(e, "warningLogItem");
|
247
|
+
}
|
248
|
+
|
249
|
+
befores = befores.clone();
|
250
|
+
if (content.beforeEach) {
|
251
|
+
befores.push(content.beforeEach);
|
252
|
+
}
|
253
|
+
afters = afters.clone();
|
254
|
+
if (content.afterEach) {
|
255
|
+
afters.unshift(content.afterEach);
|
256
|
+
}
|
257
|
+
|
258
|
+
if (content.builder) {
|
259
|
+
var extraSpecs = content.builder();
|
260
|
+
for (extraSpecName in extraSpecs) {
|
261
|
+
content[extraSpecName] = extraSpecs[extraSpecName];
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
Object.keys(content).without("beforeEach").without("afterEach").without("builder").each(function(k) {
|
266
|
+
var specName = cls.toString() + " " + k;
|
267
|
+
arg = content[k];
|
268
|
+
|
269
|
+
|
270
|
+
if (Object.isFunction(content[k]) || content[k].constructor == Function) {
|
271
|
+
var specRun = new Object();
|
272
|
+
|
273
|
+
(function() {
|
274
|
+
try {
|
275
|
+
// =============================================================
|
276
|
+
// = BEGIN TEST OVERRIDES TO ACCOUNT FOR DEFER NON-DETERMINISM =
|
277
|
+
// =============================================================
|
278
|
+
stub(rio.Undo, "_doAfterAction").andDo(function() { rio.Undo.afterAction() });
|
279
|
+
// =============================================================
|
280
|
+
// = END TEST OVERRIDES TO ACCOUNT FOR DEFER NON-DETERMINISM =
|
281
|
+
// =============================================================
|
282
|
+
context.examples++;
|
283
|
+
|
284
|
+
for (modelName in rio.models) {
|
285
|
+
var model = rio.models[modelName];
|
286
|
+
model._idCache = {};
|
287
|
+
model._identityCache = {};
|
288
|
+
model._collectionEntities = {};
|
289
|
+
model._transaction = [];
|
290
|
+
model._transactionQueued = false;
|
291
|
+
model.__transactionInProgress = false;
|
292
|
+
}
|
293
|
+
|
294
|
+
// preloadFixtures();
|
295
|
+
befores.each(function(beforeEach) { beforeEach.bind(this)() }.bind(this));
|
296
|
+
content[k].bind(this)();
|
297
|
+
mockManager.verifyAll();
|
298
|
+
stdout("- " + specName, "passed");
|
299
|
+
} catch(e) {
|
300
|
+
context.failures++;
|
301
|
+
stdout("- " + specName + "\n" + " - (" + (e.message || e) + ") " + (e.detail || ""), "failed");
|
302
|
+
} finally {
|
303
|
+
try {
|
304
|
+
for (var i=0; i<afters.length; i++) {
|
305
|
+
var afterEach = afters[i];
|
306
|
+
afterEach.bind(this)();
|
307
|
+
}
|
308
|
+
} finally {
|
309
|
+
try {
|
310
|
+
mockManager.releaseAll();
|
311
|
+
stubManager.releaseAll();
|
312
|
+
} catch(e) {
|
313
|
+
stdout("Failed to release mocks and stubs", "warningLogItem");
|
314
|
+
} finally {
|
315
|
+
specPage.reset();
|
316
|
+
}
|
317
|
+
}
|
318
|
+
}
|
319
|
+
}.bind(specRun))();
|
320
|
+
} else if (Object.isString(content[k]) && content[k] == "PENDING") {
|
321
|
+
stdout("- " + specName, "pending");
|
322
|
+
context.examples++;
|
323
|
+
context.pendings++;
|
324
|
+
} else {
|
325
|
+
that.describe(that, stdout, befores, afters, context, specPage, stubManager, mockManager, specName, content[k]);
|
326
|
+
}
|
327
|
+
});
|
328
|
+
},
|
329
|
+
|
330
|
+
toString: function() { return "Spec"; }
|
331
|
+
};
|
332
|
+
|
333
|
+
rio.Assertions = {
|
334
|
+
shouldEqual: function(val) {
|
335
|
+
this.should(val == this, "expected '" + val + "', got '" + this + "'");
|
336
|
+
},
|
337
|
+
|
338
|
+
shouldNotEqual: function(val) {
|
339
|
+
this.should(val != this, "expected not '" + val + "', got '" + this + "'");
|
340
|
+
},
|
341
|
+
|
342
|
+
shouldBeTrue: function() {
|
343
|
+
var truthy = this.valueOf() ? true : false;
|
344
|
+
this.should(truthy, "expected: 'true', got '" + this + "'");
|
345
|
+
},
|
346
|
+
|
347
|
+
shouldNotBeTrue: function() {
|
348
|
+
var truthy = this.valueOf() ? true : false;
|
349
|
+
this.shouldNot(truthy, "expected: 'false', got '" + this + "'");
|
350
|
+
},
|
351
|
+
|
352
|
+
shouldBeFalse: function() {
|
353
|
+
this.shouldNotBeTrue();
|
354
|
+
},
|
355
|
+
|
356
|
+
should: function(result, msg) {
|
357
|
+
if (!result) {
|
358
|
+
throw msg;
|
359
|
+
};
|
360
|
+
},
|
361
|
+
|
362
|
+
shouldNot: function(result, msg) {
|
363
|
+
if (result) {
|
364
|
+
throw msg;
|
365
|
+
};
|
366
|
+
}
|
367
|
+
};
|
368
|
+
|
369
|
+
Object.extend(rio.Id.prototype, rio.Assertions);
|
370
|
+
Object.extend(rio.Binding, rio.Assertions);
|
371
|
+
|
372
|
+
Object.extend(String.prototype, rio.Assertions);
|
373
|
+
Object.extend(Boolean.prototype, rio.Assertions);
|
374
|
+
Object.extend(Number.prototype, rio.Assertions);
|
375
|
+
Object.extend(Function.prototype, rio.Assertions);
|
376
|
+
Object.extend(Array.prototype, rio.Assertions);
|
377
|
+
|
378
|
+
Object.extend(String.prototype, {
|
379
|
+
shouldStartWith: function(val) {
|
380
|
+
this.should(this.startsWith(val), "expected '" + this + "' to start with '" + val + "'")
|
381
|
+
},
|
382
|
+
|
383
|
+
shouldMatch: function(val) {
|
384
|
+
this.should(this.match(val), "expected '" + this + "' to match '" + val + "'");
|
385
|
+
}
|
386
|
+
});
|
387
|
+
|
388
|
+
Object.extend(Function.prototype, {
|
389
|
+
shouldBeCalled: function() {
|
390
|
+
var count = 0;
|
391
|
+
var wrapped = this.wrap(function(proceed) {
|
392
|
+
count++;
|
393
|
+
return proceed.apply(this, $A(arguments).slice(1));
|
394
|
+
});
|
395
|
+
wrapped.expectation = function() {
|
396
|
+
return count > 0;
|
397
|
+
};
|
398
|
+
var expectation = function() {
|
399
|
+
return wrapped.expectation();
|
400
|
+
};
|
401
|
+
|
402
|
+
var original = this;
|
403
|
+
expectation.message = "\n\n" + original.toString() + "\n\n# should be called";
|
404
|
+
wrapped.times = function(times) {
|
405
|
+
wrapped.expectation = function() {
|
406
|
+
return count == times;
|
407
|
+
};
|
408
|
+
expectation.message = "\n\n" + original.toString() + "\n\n# should be called " + times + " times.";
|
409
|
+
return wrapped;
|
410
|
+
};
|
411
|
+
wrapped.once = wrapped.times.curry(1);
|
412
|
+
rio.mockManager.expect(expectation);
|
413
|
+
return wrapped;
|
414
|
+
},
|
415
|
+
|
416
|
+
shouldNotBeCalled: function() {
|
417
|
+
var wrapped = this.wrap(function(proceed) {
|
418
|
+
wrapped._called = true;
|
419
|
+
proceed.apply(this, $A(arguments).slice(1));
|
420
|
+
});
|
421
|
+
var expectation = function() {
|
422
|
+
return !wrapped._called;
|
423
|
+
};
|
424
|
+
expectation.message = "\n\n" + this.toString() + "\n\n# should not be called";
|
425
|
+
rio.mockManager.expect(expectation);
|
426
|
+
return wrapped;
|
427
|
+
}
|
428
|
+
});
|
429
|
+
|
430
|
+
Object.extend(Array.prototype, {
|
431
|
+
shouldEqual: function(val) {
|
432
|
+
var equal = true;
|
433
|
+
if (val.size != undefined && val.length == this.length) {
|
434
|
+
for (var i = 0; i < this.length; i++) {
|
435
|
+
equal = equal && this[i] == val[i];
|
436
|
+
}
|
437
|
+
} else {
|
438
|
+
equal = false;
|
439
|
+
}
|
440
|
+
this.should(equal, "expected '" + val + "', got '" + this + "'");
|
441
|
+
},
|
442
|
+
|
443
|
+
shouldInclude: function(val) {
|
444
|
+
this.should(this.include(val), "expected " + this + " to include " + val);
|
445
|
+
},
|
446
|
+
|
447
|
+
shouldNotInclude: function(val) {
|
448
|
+
this.shouldNot(this.include(val), "expected " + this + " not to include " + val);
|
449
|
+
},
|
450
|
+
|
451
|
+
shouldBeEmpty: function() {
|
452
|
+
this.should(this.empty(), "expected " + this + " to be empty");
|
453
|
+
},
|
454
|
+
|
455
|
+
shouldNotBeEmpty: function() {
|
456
|
+
this.shouldNot(this.empty(), "expected " + this + " to not be empty");
|
457
|
+
}
|
458
|
+
});
|
459
|
+
|
460
|
+
rio.Stub = Class.create({
|
461
|
+
initialize: function(object, method) {
|
462
|
+
this.object = object;
|
463
|
+
this.method = method;
|
464
|
+
this.oldMethod = this.object[this.method];
|
465
|
+
|
466
|
+
this.object[this.method] = function() {};
|
467
|
+
},
|
468
|
+
|
469
|
+
release: function() {
|
470
|
+
if (this.oldMethod == undefined) {
|
471
|
+
delete this.object[this.method];
|
472
|
+
} else {
|
473
|
+
this.object[this.method] = this.oldMethod;
|
474
|
+
}
|
475
|
+
},
|
476
|
+
|
477
|
+
andReturn: function(value) {
|
478
|
+
this.value = value;
|
479
|
+
this.object[this.method] = function() {
|
480
|
+
return value;
|
481
|
+
}
|
482
|
+
},
|
483
|
+
|
484
|
+
andDo: function(func) {
|
485
|
+
this.andDo = func;
|
486
|
+
this.object[this.method] = function() {
|
487
|
+
return func.apply(this, arguments);
|
488
|
+
}
|
489
|
+
},
|
490
|
+
|
491
|
+
withValue: function(value) {
|
492
|
+
this.object[this.method] = value;
|
493
|
+
return this;
|
494
|
+
},
|
495
|
+
|
496
|
+
shouldBeCalled: function() {
|
497
|
+
this.andDo(function() {}.shouldBeCalled());
|
498
|
+
},
|
499
|
+
|
500
|
+
shouldNotBeCalled: function() {
|
501
|
+
this.andDo(function() {}.shouldNotBeCalled());
|
502
|
+
}
|
503
|
+
});
|
504
|
+
|
505
|
+
rio.StubManager = Class.create({
|
506
|
+
initialize: function() {
|
507
|
+
this.stubs = [];
|
508
|
+
},
|
509
|
+
|
510
|
+
releaseAll: function() {
|
511
|
+
for (var i=0; i<this.stubs.length; i++) {
|
512
|
+
var stub = this.stubs[i];
|
513
|
+
stub.release();
|
514
|
+
}
|
515
|
+
this.stubs.clear();
|
516
|
+
},
|
517
|
+
|
518
|
+
stub: function(obj, method) {
|
519
|
+
var stub = new rio.Stub(obj, method);
|
520
|
+
this.stubs.unshift(stub);
|
521
|
+
return stub;
|
522
|
+
}
|
523
|
+
});
|
524
|
+
|
525
|
+
rio.MockManager = Class.create({
|
526
|
+
initialize: function() {
|
527
|
+
this.expectations = [];
|
528
|
+
},
|
529
|
+
expect: function(expectation) {
|
530
|
+
this.expectations.push(expectation);
|
531
|
+
},
|
532
|
+
verifyAll: function() {
|
533
|
+
this.expectations.each(function(expectation) {
|
534
|
+
if (!expectation()) {
|
535
|
+
throw({
|
536
|
+
message: "expectation failed",
|
537
|
+
detail: expectation.message
|
538
|
+
});
|
539
|
+
}
|
540
|
+
});
|
541
|
+
},
|
542
|
+
releaseAll: function() {
|
543
|
+
this.expectations.clear();
|
544
|
+
}
|
545
|
+
});
|