riojs 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,361 @@
|
|
|
1
|
+
describe(rio.Benchmark, {
|
|
2
|
+
beforeEach: function() {
|
|
3
|
+
rio.Benchmark.stop();
|
|
4
|
+
rio.Benchmark.clear();
|
|
5
|
+
},
|
|
6
|
+
|
|
7
|
+
afterEach: function() {
|
|
8
|
+
rio.Benchmark.stop();
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
"install wraps a method with a function that": {
|
|
12
|
+
beforeEach: function() {
|
|
13
|
+
this.obj = { hello: function() { return "world"; } };
|
|
14
|
+
rio.Benchmark.install(this.obj, "hello", "weeee");
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
"should be installed": function() {
|
|
18
|
+
rio.Benchmark.installationFor(this.obj, "hello").getInstalled().shouldBeTrue();
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
"should not be installed twice": function() {
|
|
22
|
+
rio.Benchmark.install(this.obj, "hello", "weeee");
|
|
23
|
+
rio.Benchmark.getInstallations().size().shouldEqual(1);
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
"should be removable": function() {
|
|
27
|
+
rio.Benchmark.installationFor(this.obj, "hello").isRemovable().shouldBeTrue();
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
"should keep track of the object string": function() {
|
|
31
|
+
rio.Benchmark.installationFor(this.obj, "hello").getObjectString().shouldEqual("weeee");
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
"should not keep track of the number of invocations before benchmarking is started": function() {
|
|
35
|
+
this.obj.hello();
|
|
36
|
+
rio.Benchmark.metrics(this.obj, "hello").invocations.shouldEqual(0);
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
"should keep track of the number of invocations after benchmarking is started": function() {
|
|
40
|
+
rio.Benchmark.start();
|
|
41
|
+
this.obj.hello();
|
|
42
|
+
this.obj.hello();
|
|
43
|
+
rio.Benchmark.metrics(this.obj, "hello").invocations.shouldEqual(2);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
"should not keep track of the number of invocations after benchmarking is started if it is not enabled": function() {
|
|
47
|
+
rio.Benchmark.start();
|
|
48
|
+
rio.Benchmark.installationFor(this.obj, "hello").setEnabled(false);
|
|
49
|
+
this.obj.hello();
|
|
50
|
+
this.obj.hello();
|
|
51
|
+
rio.Benchmark.metrics(this.obj, "hello").invocations.shouldEqual(0);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
"should stop keeping track of the number of invocations after benchmarking is stopped": function() {
|
|
55
|
+
rio.Benchmark.start();
|
|
56
|
+
this.obj.hello();
|
|
57
|
+
rio.Benchmark.stop();
|
|
58
|
+
this.obj.hello();
|
|
59
|
+
rio.Benchmark.metrics(this.obj, "hello").invocations.shouldEqual(1);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
"should still return the proper value": function() {
|
|
63
|
+
this.obj.hello().shouldEqual("world");
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
"should reset the number of invocations after benchmarking is restarted": function() {
|
|
67
|
+
rio.Benchmark.start();
|
|
68
|
+
this.obj.hello();
|
|
69
|
+
rio.Benchmark.stop();
|
|
70
|
+
rio.Benchmark.start();
|
|
71
|
+
rio.Benchmark.metrics(this.obj, "hello").invocations.shouldEqual(0);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
"should not keep track of the total invocation time before benchmarking is started": function() {
|
|
75
|
+
var oldDate = Date;
|
|
76
|
+
var times = [1,6];
|
|
77
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
78
|
+
try {
|
|
79
|
+
this.obj.hello();
|
|
80
|
+
rio.Benchmark.metrics(this.obj, "hello").time.shouldEqual(0);
|
|
81
|
+
} finally {
|
|
82
|
+
Date = oldDate;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
"should keep track of the total invocation time": function() {
|
|
87
|
+
var oldDate = Date;
|
|
88
|
+
var times = [1,6,2,7];
|
|
89
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
90
|
+
try {
|
|
91
|
+
rio.Benchmark.start();
|
|
92
|
+
this.obj.hello();
|
|
93
|
+
this.obj.hello();
|
|
94
|
+
rio.Benchmark.stop();
|
|
95
|
+
rio.Benchmark.metrics(this.obj, "hello").time.shouldEqual(10);
|
|
96
|
+
} finally {
|
|
97
|
+
Date = oldDate;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
"should stop keeping track of the number of the total invocation time after benchmarking is stopped": function() {
|
|
102
|
+
var oldDate = Date;
|
|
103
|
+
var times = [1,6,2,7];
|
|
104
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
105
|
+
try {
|
|
106
|
+
rio.Benchmark.start();
|
|
107
|
+
this.obj.hello();
|
|
108
|
+
rio.Benchmark.stop();
|
|
109
|
+
this.obj.hello();
|
|
110
|
+
rio.Benchmark.metrics(this.obj, "hello").time.shouldEqual(5);
|
|
111
|
+
} finally {
|
|
112
|
+
Date = oldDate;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
"should reset the total invocation time after benchmarking is restarted": function() {
|
|
117
|
+
var oldDate = Date;
|
|
118
|
+
var times = [1,6];
|
|
119
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
120
|
+
try {
|
|
121
|
+
rio.Benchmark.start();
|
|
122
|
+
this.obj.hello();
|
|
123
|
+
rio.Benchmark.stop();
|
|
124
|
+
rio.Benchmark.start();
|
|
125
|
+
rio.Benchmark.metrics(this.obj, "hello").time.shouldEqual(0);
|
|
126
|
+
} finally {
|
|
127
|
+
Date = oldDate;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
"should be removed on Benchmark.clear": function() {
|
|
132
|
+
rio.Benchmark.clear();
|
|
133
|
+
rio.Benchmark.getInstallations().shouldBeEmpty();
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
"should can be uninstalled": function() {
|
|
137
|
+
var installation = rio.Benchmark.installationFor(this.obj, "hello");
|
|
138
|
+
installation.uninstall();
|
|
139
|
+
installation.getInstalled().shouldBeFalse();
|
|
140
|
+
rio.Benchmark.getInstallations().shouldNotInclude(installation);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
"should determine the object string from the object if its not provided": function() {
|
|
146
|
+
var obj = {hello: function() {}, toString: function() {return "goat";}};
|
|
147
|
+
|
|
148
|
+
rio.Benchmark.install(obj, "hello");
|
|
149
|
+
|
|
150
|
+
rio.Benchmark.installationFor(obj, "hello").getObjectString().shouldEqual("goat");
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
"should support prototype benchmarking for classes": function() {
|
|
154
|
+
var cls = Class.create({
|
|
155
|
+
hello: function() {}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
rio.Benchmark.install(cls.prototype, "hello");
|
|
159
|
+
|
|
160
|
+
var clsInstance = new cls();
|
|
161
|
+
|
|
162
|
+
rio.Benchmark.start();
|
|
163
|
+
|
|
164
|
+
clsInstance.hello();
|
|
165
|
+
|
|
166
|
+
rio.Benchmark.metrics(cls.prototype, "hello").invocations.shouldEqual(1);
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
"should not double count time as a result of recursion": function() {
|
|
170
|
+
var obj = {
|
|
171
|
+
hello: function(val) {
|
|
172
|
+
if (val < 1) {
|
|
173
|
+
return;
|
|
174
|
+
} else {
|
|
175
|
+
return obj.hello(val - 1);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
rio.Benchmark.install(obj, "hello");
|
|
181
|
+
|
|
182
|
+
var oldDate = Date;
|
|
183
|
+
var times = [1,11];
|
|
184
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
185
|
+
try {
|
|
186
|
+
rio.Benchmark.start();
|
|
187
|
+
obj.hello(2);
|
|
188
|
+
rio.Benchmark.stop();
|
|
189
|
+
rio.Benchmark.metrics(obj, "hello").invocations.shouldEqual(3);
|
|
190
|
+
rio.Benchmark.metrics(obj, "hello").time.shouldEqual(10);
|
|
191
|
+
} finally {
|
|
192
|
+
Date = oldDate;
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
"begin creates a finer grained benchmark that": {
|
|
197
|
+
"should add an installation with an object string of [WAYPOINT]": function() {
|
|
198
|
+
rio.Benchmark.begin("hello");
|
|
199
|
+
|
|
200
|
+
rio.Benchmark.installationFor("hello").getObjectString().shouldEqual("[WAYPOINT]");
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
"should add an installation with a method name equal to the waypoint name": function() {
|
|
204
|
+
rio.Benchmark.begin("hello");
|
|
205
|
+
|
|
206
|
+
rio.Benchmark.installationFor("hello").getMethodName().shouldEqual("hello");
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
"should not keep track of how many times begin is called for a particular waypoint before benchmarking is started": function() {
|
|
210
|
+
rio.Benchmark.begin("hello");
|
|
211
|
+
rio.Benchmark.metrics("hello").invocations.shouldEqual(0);
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
"should keep track of how many times begin is called for a particular waypoint": function() {
|
|
215
|
+
rio.Benchmark.start();
|
|
216
|
+
rio.Benchmark.begin("world");
|
|
217
|
+
rio.Benchmark.begin("hello");
|
|
218
|
+
rio.Benchmark.begin("hello");
|
|
219
|
+
rio.Benchmark.begin("world");
|
|
220
|
+
rio.Benchmark.begin("world");
|
|
221
|
+
|
|
222
|
+
rio.Benchmark.metrics("hello").invocations.shouldEqual(2);
|
|
223
|
+
rio.Benchmark.metrics("world").invocations.shouldEqual(3);
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
"should not add time to a waypoint when it is ended before benchmarking is started": function() {
|
|
227
|
+
var oldDate = Date;
|
|
228
|
+
var times = [1,11];
|
|
229
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
230
|
+
try {
|
|
231
|
+
rio.Benchmark.begin("hello");
|
|
232
|
+
rio.Benchmark.end("hello");
|
|
233
|
+
rio.Benchmark.metrics("hello").time.shouldEqual(0);
|
|
234
|
+
} finally {
|
|
235
|
+
Date = oldDate;
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
"should add time to a waypoint when it is ended": function() {
|
|
240
|
+
var oldDate = Date;
|
|
241
|
+
var times = [1,11];
|
|
242
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
243
|
+
try {
|
|
244
|
+
rio.Benchmark.start();
|
|
245
|
+
rio.Benchmark.begin("hello");
|
|
246
|
+
rio.Benchmark.end("hello");
|
|
247
|
+
rio.Benchmark.metrics("hello").invocations.shouldEqual(1);
|
|
248
|
+
rio.Benchmark.metrics("hello").time.shouldEqual(10);
|
|
249
|
+
} finally {
|
|
250
|
+
Date = oldDate;
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
"should not double count waypoint time as a result of nesting": function() {
|
|
255
|
+
var oldDate = Date;
|
|
256
|
+
var times = [1,11,19,28];
|
|
257
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
258
|
+
try {
|
|
259
|
+
rio.Benchmark.start();
|
|
260
|
+
rio.Benchmark.begin("hello");
|
|
261
|
+
rio.Benchmark.begin("hello");
|
|
262
|
+
rio.Benchmark.end("hello");
|
|
263
|
+
rio.Benchmark.end("hello");
|
|
264
|
+
rio.Benchmark.metrics("hello").time.shouldEqual(10);
|
|
265
|
+
} finally {
|
|
266
|
+
Date = oldDate;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
"should not record any time for a waypoint that hasn't closed its outer most end": function() {
|
|
271
|
+
var oldDate = Date;
|
|
272
|
+
var times = [1,11,19,28];
|
|
273
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
274
|
+
try {
|
|
275
|
+
rio.Benchmark.start();
|
|
276
|
+
rio.Benchmark.begin("hello");
|
|
277
|
+
rio.Benchmark.begin("hello");
|
|
278
|
+
rio.Benchmark.end("hello");
|
|
279
|
+
rio.Benchmark.metrics("hello").time.shouldEqual(0);
|
|
280
|
+
} finally {
|
|
281
|
+
Date = oldDate;
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
"should not record any time or invocations for a waypoint that is not enabled": function() {
|
|
286
|
+
var oldDate = Date;
|
|
287
|
+
var times = [1,11];
|
|
288
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
289
|
+
try {
|
|
290
|
+
rio.Benchmark.begin("hello");
|
|
291
|
+
rio.Benchmark.installationFor("hello").setEnabled(false);
|
|
292
|
+
|
|
293
|
+
rio.Benchmark.start();
|
|
294
|
+
rio.Benchmark.begin("hello");
|
|
295
|
+
rio.Benchmark.end("hello");
|
|
296
|
+
rio.Benchmark.metrics("hello").invocations.shouldEqual(0);
|
|
297
|
+
rio.Benchmark.metrics("hello").time.shouldEqual(0);
|
|
298
|
+
} finally {
|
|
299
|
+
Date = oldDate;
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
"should not be removable": function() {
|
|
304
|
+
rio.Benchmark.begin("hello");
|
|
305
|
+
rio.Benchmark.installationFor("hello").isRemovable().shouldBeFalse();
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
"count creates a very small benchmark that": {
|
|
310
|
+
"should add an installation with an object string of [COUNT]": function() {
|
|
311
|
+
rio.Benchmark.count("hello");
|
|
312
|
+
|
|
313
|
+
rio.Benchmark.installationFor("hello").getObjectString().shouldEqual("[COUNT]");
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
"should add an installation with a method name equal to the count name": function() {
|
|
317
|
+
rio.Benchmark.count("hello");
|
|
318
|
+
|
|
319
|
+
rio.Benchmark.installationFor("hello").getMethodName().shouldEqual("hello");
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
"should not keep track of how many times count is called for a particular waypoint before benchmarking is started": function() {
|
|
323
|
+
rio.Benchmark.count("hello");
|
|
324
|
+
rio.Benchmark.metrics("hello").invocations.shouldEqual(0);
|
|
325
|
+
},
|
|
326
|
+
|
|
327
|
+
"should keep track of how many times count is called for a particular waypoint": function() {
|
|
328
|
+
rio.Benchmark.start();
|
|
329
|
+
rio.Benchmark.count("world");
|
|
330
|
+
rio.Benchmark.count("hello");
|
|
331
|
+
rio.Benchmark.count("hello");
|
|
332
|
+
rio.Benchmark.count("world");
|
|
333
|
+
rio.Benchmark.count("world");
|
|
334
|
+
|
|
335
|
+
rio.Benchmark.metrics("hello").invocations.shouldEqual(2);
|
|
336
|
+
rio.Benchmark.metrics("world").invocations.shouldEqual(3);
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
"should not add time": function() {
|
|
340
|
+
var oldDate = Date;
|
|
341
|
+
var times = [1,11];
|
|
342
|
+
Date = function() { return { getTime: function() { return times.shift(); } }; };
|
|
343
|
+
try {
|
|
344
|
+
rio.Benchmark.count("hello");
|
|
345
|
+
rio.Benchmark.count("hello");
|
|
346
|
+
rio.Benchmark.metrics("hello").time.shouldEqual(0);
|
|
347
|
+
} finally {
|
|
348
|
+
Date = oldDate;
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
"should not be removable": function() {
|
|
353
|
+
rio.Benchmark.count("hello");
|
|
354
|
+
rio.Benchmark.installationFor("hello").isRemovable().shouldBeFalse();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
describe(rio.CollectionEntity, {
|
|
2
|
+
"with no condition function": {
|
|
3
|
+
beforeEach: function() {
|
|
4
|
+
this.model = rio.Model.create({
|
|
5
|
+
resource: "/resource",
|
|
6
|
+
attrAccessors: ["id", "name"]
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
this.values = [
|
|
10
|
+
new this.model({ id: 1, name: "apples" }),
|
|
11
|
+
new this.model({ id: 2, name: "oranges" })
|
|
12
|
+
];
|
|
13
|
+
this.collectionEntity = rio.CollectionEntity.create({
|
|
14
|
+
model: this.model,
|
|
15
|
+
values: this.values
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
"should have a reference to a rio.Model": function() {
|
|
20
|
+
(this.collectionEntity.getModel() == this.model).shouldBeTrue();
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
"should allow array style reference of values": function() {
|
|
24
|
+
(this.collectionEntity[0] == this.values[0]).shouldBeTrue();
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
"should add an object to the collection if the model matches": function() {
|
|
28
|
+
var newEntity = new this.model({ id: 3, name: "banana" });
|
|
29
|
+
this.collectionEntity.add(newEntity);
|
|
30
|
+
this.collectionEntity.shouldInclude(newEntity);
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
"should not add an object to the collection if the model does not match": function() {
|
|
34
|
+
var differentModel = rio.Model.create();
|
|
35
|
+
var newEntity = new differentModel();
|
|
36
|
+
this.collectionEntity.add(newEntity);
|
|
37
|
+
this.collectionEntity.shouldNotInclude(newEntity);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
"with condition function": {
|
|
42
|
+
beforeEach: function() {
|
|
43
|
+
this.model = rio.Model.create({
|
|
44
|
+
resource: "/resource",
|
|
45
|
+
attrAccessors: ["id", "name"]
|
|
46
|
+
});
|
|
47
|
+
stub(rio.models, "Resource").withValue(this.model);
|
|
48
|
+
this.model.prepareTransaction = function() {
|
|
49
|
+
this.executeTransaction(rio.Undo.isProcessingUndo(), rio.Undo.isProcessingRedo());
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
this.collectionEntity = rio.CollectionEntity.create({
|
|
53
|
+
model: this.model,
|
|
54
|
+
values: [],
|
|
55
|
+
condition: function(val) {
|
|
56
|
+
return val.getName() == "Jason";
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
"should add an object to the collection if the model matches and the condition function evaluates true": function() {
|
|
62
|
+
var newEntity = new this.model({ id: 1, name: "Jason" });
|
|
63
|
+
this.collectionEntity.add(newEntity);
|
|
64
|
+
this.collectionEntity.shouldInclude(newEntity);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
"should add an object to the collection on update if the model matches and the condition function evaluates true": function() {
|
|
68
|
+
var newEntity = new this.model({ id: 1, name: "Jason" });
|
|
69
|
+
this.collectionEntity.update(newEntity);
|
|
70
|
+
this.collectionEntity.shouldInclude(newEntity);
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
"should remove an object from the collection on update if the model matches but the condition function evaluates false": function() {
|
|
74
|
+
var newEntity = new this.model({ id: 1, name: "Jason" });
|
|
75
|
+
this.collectionEntity.add(newEntity);
|
|
76
|
+
|
|
77
|
+
newEntity.setName("Bob");
|
|
78
|
+
this.collectionEntity.update(newEntity);
|
|
79
|
+
|
|
80
|
+
this.collectionEntity.shouldNotInclude(newEntity);
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
"should not add an object to the collection on update if entity is being destroyed": function() {
|
|
84
|
+
var newEntity = new this.model({ id: 1, name: "Jason" });
|
|
85
|
+
|
|
86
|
+
newEntity.destroy();
|
|
87
|
+
|
|
88
|
+
this.collectionEntity.update(newEntity);
|
|
89
|
+
|
|
90
|
+
this.collectionEntity.shouldNotInclude(newEntity);
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
"should not add an object if the model does not match": function() {
|
|
94
|
+
var differentModel = rio.Model.create({
|
|
95
|
+
resource: "/different_resource",
|
|
96
|
+
attrAccessors: ["id", "name"]
|
|
97
|
+
});
|
|
98
|
+
var newEntity = new differentModel({ id: 2, name: "Jason" });
|
|
99
|
+
this.collectionEntity.add(newEntity);
|
|
100
|
+
this.collectionEntity.shouldNotInclude(newEntity);
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
"should not add an object if the condition function evaluates false": function() {
|
|
104
|
+
var newEntity = new this.model({ id: 1, name: "Bob" });
|
|
105
|
+
this.collectionEntity.add(newEntity);
|
|
106
|
+
this.collectionEntity.shouldNotInclude(newEntity);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|