rack-allocation_stats 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +7 -0
- data/LICENSE +195 -0
- data/README.markdown +114 -0
- data/TODO.markdown +31 -0
- data/lib/rack/allocation_stats/help.txt +19 -0
- data/lib/rack/allocation_stats/interactive/allocations.js.erb +24 -0
- data/lib/rack/allocation_stats/interactive/index.html.erb +109 -0
- data/lib/rack/allocation_stats/interactive/interactive.js +274 -0
- data/lib/rack/allocation_stats/interactive/jquery-2.0.3.min.js +6 -0
- data/lib/rack/allocation_stats/interactive/jquery-ui-1.10.3.custom.min.css +6 -0
- data/lib/rack/allocation_stats/interactive/jquery-ui-1.10.3.custom.min.js +6 -0
- data/lib/rack/allocation_stats/interactive/sizzle.min.js +5 -0
- data/lib/rack/allocation_stats/interactive/style.css +104 -0
- data/lib/rack/allocation_stats/interactive/style.scss +147 -0
- data/lib/rack/allocation_stats/interactive/underscore-min.js +6 -0
- data/spec/hello_world.ru +8 -0
- data/spec/javascripts/css/docco.css +186 -0
- data/spec/javascripts/css/jasmine_docco-1.3.1.css +363 -0
- data/spec/javascripts/interactive_spec.html +220 -0
- data/spec/javascripts/interactive_spec.html.mustache +78 -0
- data/spec/javascripts/interactive_spec.js +110 -0
- data/spec/javascripts/js/jasmine-html.js +681 -0
- data/spec/javascripts/js/jasmine.css +82 -0
- data/spec/javascripts/js/jasmine.js +2600 -0
- data/spec/sinatra.ru +8 -0
- data/spec/sinatra_templates.ru +8 -0
- data/spec/sinatra_templates_app.rb +1 -1
- data/spec/yajl.ru +8 -0
- data/spec/yaml.ru +8 -0
- metadata +58 -97
- data/demo_rack_apps/Rails_3.2.15/app/controllers/application_controller.rb +0 -3
- data/demo_rack_apps/Rails_3.2.15/app/controllers/projects_controller.rb +0 -83
- data/demo_rack_apps/Rails_3.2.15/app/controllers/tasks_controller.rb +0 -83
- data/demo_rack_apps/Rails_3.2.15/app/helpers/application_helper.rb +0 -2
- data/demo_rack_apps/Rails_3.2.15/app/helpers/projects_helper.rb +0 -2
- data/demo_rack_apps/Rails_3.2.15/app/helpers/tasks_helper.rb +0 -2
- data/demo_rack_apps/Rails_3.2.15/app/models/project.rb +0 -4
- data/demo_rack_apps/Rails_3.2.15/app/models/task.rb +0 -4
- data/demo_rack_apps/Rails_3.2.15/config/application.rb +0 -63
- data/demo_rack_apps/Rails_3.2.15/config/boot.rb +0 -6
- data/demo_rack_apps/Rails_3.2.15/config/environment.rb +0 -5
- data/demo_rack_apps/Rails_3.2.15/config/environments/development.rb +0 -37
- data/demo_rack_apps/Rails_3.2.15/config/environments/production.rb +0 -67
- data/demo_rack_apps/Rails_3.2.15/config/environments/test.rb +0 -37
- data/demo_rack_apps/Rails_3.2.15/config/initializers/backtrace_silencers.rb +0 -7
- data/demo_rack_apps/Rails_3.2.15/config/initializers/inflections.rb +0 -15
- data/demo_rack_apps/Rails_3.2.15/config/initializers/mime_types.rb +0 -5
- data/demo_rack_apps/Rails_3.2.15/config/initializers/secret_token.rb +0 -7
- data/demo_rack_apps/Rails_3.2.15/config/initializers/session_store.rb +0 -8
- data/demo_rack_apps/Rails_3.2.15/config/initializers/wrap_parameters.rb +0 -14
- data/demo_rack_apps/Rails_3.2.15/config/routes.rb +0 -64
- data/demo_rack_apps/Rails_3.2.15/db/migrate/20131104031828_create_projects.rb +0 -11
- data/demo_rack_apps/Rails_3.2.15/db/migrate/20131104031829_create_tasks.rb +0 -11
- data/demo_rack_apps/Rails_3.2.15/db/schema.rb +0 -32
- data/demo_rack_apps/Rails_3.2.15/db/seeds.rb +0 -15
- data/demo_rack_apps/Rails_3.2.15/test/functional/projects_controller_test.rb +0 -49
- data/demo_rack_apps/Rails_3.2.15/test/functional/tasks_controller_test.rb +0 -49
- data/demo_rack_apps/Rails_3.2.15/test/performance/browsing_test.rb +0 -12
- data/demo_rack_apps/Rails_3.2.15/test/test_helper.rb +0 -13
- data/demo_rack_apps/Rails_3.2.15/test/unit/helpers/projects_helper_test.rb +0 -4
- data/demo_rack_apps/Rails_3.2.15/test/unit/helpers/tasks_helper_test.rb +0 -4
- data/demo_rack_apps/Rails_3.2.15/test/unit/project_test.rb +0 -7
- data/demo_rack_apps/Rails_3.2.15/test/unit/task_test.rb +0 -7
- data/demo_rack_apps/Rails_4.0.1/app/controllers/application_controller.rb +0 -5
- data/demo_rack_apps/Rails_4.0.1/app/controllers/projects_controller.rb +0 -74
- data/demo_rack_apps/Rails_4.0.1/app/controllers/tasks_controller.rb +0 -74
- data/demo_rack_apps/Rails_4.0.1/app/helpers/application_helper.rb +0 -2
- data/demo_rack_apps/Rails_4.0.1/app/helpers/projects_helper.rb +0 -2
- data/demo_rack_apps/Rails_4.0.1/app/helpers/tasks_helper.rb +0 -2
- data/demo_rack_apps/Rails_4.0.1/app/models/project.rb +0 -3
- data/demo_rack_apps/Rails_4.0.1/app/models/task.rb +0 -3
- data/demo_rack_apps/Rails_4.0.1/config/application.rb +0 -24
- data/demo_rack_apps/Rails_4.0.1/config/boot.rb +0 -4
- data/demo_rack_apps/Rails_4.0.1/config/environment.rb +0 -5
- data/demo_rack_apps/Rails_4.0.1/config/environments/development.rb +0 -29
- data/demo_rack_apps/Rails_4.0.1/config/environments/production.rb +0 -80
- data/demo_rack_apps/Rails_4.0.1/config/environments/test.rb +0 -36
- data/demo_rack_apps/Rails_4.0.1/config/initializers/backtrace_silencers.rb +0 -7
- data/demo_rack_apps/Rails_4.0.1/config/initializers/filter_parameter_logging.rb +0 -4
- data/demo_rack_apps/Rails_4.0.1/config/initializers/inflections.rb +0 -16
- data/demo_rack_apps/Rails_4.0.1/config/initializers/mime_types.rb +0 -5
- data/demo_rack_apps/Rails_4.0.1/config/initializers/secret_token.rb +0 -12
- data/demo_rack_apps/Rails_4.0.1/config/initializers/session_store.rb +0 -3
- data/demo_rack_apps/Rails_4.0.1/config/initializers/wrap_parameters.rb +0 -14
- data/demo_rack_apps/Rails_4.0.1/config/routes.rb +0 -60
- data/demo_rack_apps/Rails_4.0.1/db/migrate/20131102201320_create_projects.rb +0 -11
- data/demo_rack_apps/Rails_4.0.1/db/migrate/20131102201321_create_tasks.rb +0 -11
- data/demo_rack_apps/Rails_4.0.1/db/schema.rb +0 -32
- data/demo_rack_apps/Rails_4.0.1/db/seeds.rb +0 -15
- data/demo_rack_apps/Rails_4.0.1/test/controllers/projects_controller_test.rb +0 -49
- data/demo_rack_apps/Rails_4.0.1/test/controllers/tasks_controller_test.rb +0 -49
- data/demo_rack_apps/Rails_4.0.1/test/helpers/projects_helper_test.rb +0 -4
- data/demo_rack_apps/Rails_4.0.1/test/helpers/tasks_helper_test.rb +0 -4
- data/demo_rack_apps/Rails_4.0.1/test/models/project_test.rb +0 -7
- data/demo_rack_apps/Rails_4.0.1/test/models/task_test.rb +0 -7
- data/demo_rack_apps/Rails_4.0.1/test/test_helper.rb +0 -15
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
|
5
|
+
<title>Rack AllocationStats - interactive output specs</title>
|
|
6
|
+
<link href='http://fonts.googleapis.com/css?family=Lora|Istok+Web:700' rel='stylesheet' type='text/css'/>
|
|
7
|
+
<link rel="stylesheet" href="css/docco.css"/>
|
|
8
|
+
<link rel="stylesheet" href="css/jasmine_docco-1.3.1.css"/>
|
|
9
|
+
<link rel="stylesheet" href="js/jasmine.css"/>
|
|
10
|
+
<script src="js/jasmine.js"></script>
|
|
11
|
+
<script src="js/jasmine-html.js"></script>
|
|
12
|
+
<script src="../../lib/rack/allocation_stats/interactive/jquery-2.0.3.min.js"></script>
|
|
13
|
+
<script src="../../lib/rack/allocation_stats/interactive/underscore-min.js"></script>
|
|
14
|
+
<script src="../../lib/rack/allocation_stats/interactive/interactive.js"></script>
|
|
15
|
+
<script src="interactive_spec.js"></script>
|
|
16
|
+
<script>
|
|
17
|
+
(function() {
|
|
18
|
+
var jasmineEnv = jasmine.getEnv();
|
|
19
|
+
jasmineEnv.updateInterval = 250;
|
|
20
|
+
|
|
21
|
+
var htmlReporter = new jasmine.HtmlReporter();
|
|
22
|
+
jasmineEnv.addReporter(htmlReporter);
|
|
23
|
+
|
|
24
|
+
jasmineEnv.specFilter = function(spec) {
|
|
25
|
+
return htmlReporter.specFilter(spec);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var currentWindowOnload = window.onload;
|
|
29
|
+
window.onload = function() {
|
|
30
|
+
if (currentWindowOnload) {
|
|
31
|
+
currentWindowOnload();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
execJasmine();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function execJasmine() {
|
|
38
|
+
jasmineEnv.execute();
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
</script>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<div id="container">
|
|
45
|
+
<div id="background"></div>
|
|
46
|
+
<div class="banner">
|
|
47
|
+
<a href="#">Rack AllocationStats</a>
|
|
48
|
+
</div>
|
|
49
|
+
<table cellspacing="0" cellpadding="0">
|
|
50
|
+
<thead>
|
|
51
|
+
<tr>
|
|
52
|
+
<th class="docs">
|
|
53
|
+
<h1>interactive_spec.js</h1>
|
|
54
|
+
</th>
|
|
55
|
+
<th class="code"></th>
|
|
56
|
+
</tr>
|
|
57
|
+
</thead>
|
|
58
|
+
<tbody>
|
|
59
|
+
<tr id="section-1">
|
|
60
|
+
<td class="docs">
|
|
61
|
+
<div class="pilwrap">
|
|
62
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
</td>
|
|
66
|
+
<td class="code">
|
|
67
|
+
<div class="highlight">
|
|
68
|
+
<pre><span class="cm">/* Copyright 2013 Google Inc. All Rights Reserved.</span>
|
|
69
|
+
<span class="cm"> * Licensed under the Apache License, Version 2.0, found in the LICENSE file.</span>
|
|
70
|
+
<span class="cm"> */</span></pre>
|
|
71
|
+
</div>
|
|
72
|
+
</td>
|
|
73
|
+
</tr>
|
|
74
|
+
<tr id="section-2">
|
|
75
|
+
<td class="docs">
|
|
76
|
+
<div class="pilwrap">
|
|
77
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
|
78
|
+
</div>
|
|
79
|
+
<p>Rack AllocationStats is…</p>
|
|
80
|
+
</td>
|
|
81
|
+
<td class="code">
|
|
82
|
+
<div class="highlight">
|
|
83
|
+
<pre></pre>
|
|
84
|
+
</div>
|
|
85
|
+
</td>
|
|
86
|
+
</tr>
|
|
87
|
+
<tr id="section-abbreviateClass()">
|
|
88
|
+
<td class="docs">
|
|
89
|
+
<div class="pilwrap">
|
|
90
|
+
<a class="pilcrow" href="#section-abbreviateClass()">¶</a>
|
|
91
|
+
</div>
|
|
92
|
+
<h2>abbreviateClass()</h2>
|
|
93
|
+
|
|
94
|
+
<p><code>abbreviateClass()</code> is a method that abbreviates the inside namespaces of a
|
|
95
|
+
long Ruby class name. Examples:</p>
|
|
96
|
+
|
|
97
|
+
<p>Array => Array
|
|
98
|
+
Arel::Attributes::Attribute => Arel::…::Attribute</p>
|
|
99
|
+
</td>
|
|
100
|
+
<td class="code">
|
|
101
|
+
<div class="highlight">
|
|
102
|
+
<pre><span class="nx">describe</span><span class="p">(</span><span class="s2">"abbreviateClass"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
103
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"leaves classes with < 3 namespaces alone"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
104
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"Array"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"Array"</span><span class="p">);</span>
|
|
105
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"File::Stat"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"File::Stat"</span><span class="p">);</span>
|
|
106
|
+
<span class="p">});</span>
|
|
107
|
+
|
|
108
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"abbreviates classes with > 3 namespaces"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
109
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"Arel::Attributes::Attribute"</span><span class="p">)).</span>
|
|
110
|
+
<span class="nx">toBe</span><span class="p">(</span><span class="s1">'<abbr title="Arel::Attributes::Attribute">Arel::Att&hellip;Attribute</abbr>'</span><span class="p">);</span>
|
|
111
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"ActionDispatch::Routing::RouteSet::Generator"</span><span class="p">)).</span>
|
|
112
|
+
<span class="nx">toBe</span><span class="p">(</span><span class="s1">'<abbr title="ActionDispatch::Routing::RouteSet::Generator">ActionDispatch::Rou&hellip;Generator</abbr>'</span><span class="p">);</span>
|
|
113
|
+
<span class="p">});</span>
|
|
114
|
+
|
|
115
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"abbreviates subclasses when >= 3 namespaces"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
116
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"Array<String>"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"Array<String>"</span><span class="p">);</span>
|
|
117
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"Array<Fixnum,String>"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"Array<Fixnum,String>"</span><span class="p">);</span>
|
|
118
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"Array<Arel::Nodes::Equality>"</span><span class="p">)).</span>
|
|
119
|
+
<span class="nx">toBe</span><span class="p">(</span><span class="s1">'<abbr title="Array<Arel::Nodes::Equality>">Array<Arel::Nod&hellip;Equality></abbr>'</span><span class="p">);</span>
|
|
120
|
+
<span class="p">});</span>
|
|
121
|
+
|
|
122
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"doesn't abbreviate when only 3 namespaces and middle has < 5 letters"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
123
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">abbreviateClass</span><span class="p">(</span><span class="s2">"ActionDispatch::Http::ParameterFilter"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"ActionDispatch::Http::ParameterFilter"</span><span class="p">);</span>
|
|
124
|
+
<span class="p">});</span>
|
|
125
|
+
<span class="p">});</span></pre>
|
|
126
|
+
</div>
|
|
127
|
+
</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr id="section-getParameterByName()">
|
|
130
|
+
<td class="docs">
|
|
131
|
+
<div class="pilwrap">
|
|
132
|
+
<a class="pilcrow" href="#section-getParameterByName()">¶</a>
|
|
133
|
+
</div>
|
|
134
|
+
<h2>getParameterByName()</h2>
|
|
135
|
+
|
|
136
|
+
<p><code>getParameterByName()</code> is a method that grabs a URL parameter from
|
|
137
|
+
location.search by name. It’s amazing this isn’t directly available.</p>
|
|
138
|
+
</td>
|
|
139
|
+
<td class="code">
|
|
140
|
+
<div class="highlight">
|
|
141
|
+
<pre><span class="nx">describe</span><span class="p">(</span><span class="s2">"getParameterByName"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
142
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"returns blank if parameter not present"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
143
|
+
<span class="nx">spyOn</span><span class="p">(</span><span class="nx">util</span><span class="p">,</span> <span class="s2">"locationSearch"</span><span class="p">).</span><span class="nx">andReturn</span><span class="p">(</span><span class="s2">"?a[b]=c"</span><span class="p">);</span>
|
|
144
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"c"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">""</span><span class="p">);</span>
|
|
145
|
+
<span class="p">});</span>
|
|
146
|
+
|
|
147
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"returns parameters by name when one parameter is present"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
148
|
+
<span class="nx">spyOn</span><span class="p">(</span><span class="nx">util</span><span class="p">,</span> <span class="s2">"locationSearch"</span><span class="p">).</span><span class="nx">andReturn</span><span class="p">(</span><span class="s2">"?a=b"</span><span class="p">);</span>
|
|
149
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"b"</span><span class="p">);</span>
|
|
150
|
+
<span class="p">});</span>
|
|
151
|
+
|
|
152
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"returns parameters by name when one bracketed parameter is present"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
153
|
+
<span class="nx">spyOn</span><span class="p">(</span><span class="nx">util</span><span class="p">,</span> <span class="s2">"locationSearch"</span><span class="p">).</span><span class="nx">andReturn</span><span class="p">(</span><span class="s2">"?a[b]=c"</span><span class="p">);</span>
|
|
154
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a[b]"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"c"</span><span class="p">);</span>
|
|
155
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a[c]"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">""</span><span class="p">);</span>
|
|
156
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">""</span><span class="p">);</span>
|
|
157
|
+
<span class="p">});</span>
|
|
158
|
+
|
|
159
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"returns parameters by name when multiple parameters are present"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
160
|
+
<span class="nx">spyOn</span><span class="p">(</span><span class="nx">util</span><span class="p">,</span> <span class="s2">"locationSearch"</span><span class="p">).</span><span class="nx">andReturn</span><span class="p">(</span><span class="s2">"?a=b&c=d"</span><span class="p">);</span>
|
|
161
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"b"</span><span class="p">);</span>
|
|
162
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"c"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"d"</span><span class="p">);</span>
|
|
163
|
+
<span class="p">});</span>
|
|
164
|
+
|
|
165
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"returns parameters by name when multiple bracketed parameters are present"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
166
|
+
<span class="nx">spyOn</span><span class="p">(</span><span class="nx">util</span><span class="p">,</span> <span class="s2">"locationSearch"</span><span class="p">).</span><span class="nx">andReturn</span><span class="p">(</span><span class="s2">"?a[b]=c&a[d]=e"</span><span class="p">);</span>
|
|
167
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a[b]"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"c"</span><span class="p">);</span>
|
|
168
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a[d]"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">"e"</span><span class="p">);</span>
|
|
169
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">getParameterByName</span><span class="p">(</span><span class="s2">"a[e]"</span><span class="p">)).</span><span class="nx">toBe</span><span class="p">(</span><span class="s2">""</span><span class="p">);</span>
|
|
170
|
+
<span class="p">});</span>
|
|
171
|
+
<span class="p">});</span>
|
|
172
|
+
|
|
173
|
+
<span class="nx">describe</span><span class="p">(</span><span class="s2">"filterOutPwd"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
174
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"filters out allocations with a sourcefile in PWD"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
175
|
+
<span class="kd">var</span> <span class="nx">a1</span> <span class="o">=</span> <span class="p">{</span> <span class="kr">class</span><span class="o">:</span> <span class="s1">'Thread::ConditionVariable'</span><span class="p">,</span>
|
|
176
|
+
<span class="nx">file</span><span class="o">:</span> <span class="s1">'<RUBYLIBDIR>/monitor.rb'</span> <span class="p">},</span>
|
|
177
|
+
<span class="nx">a2</span> <span class="o">=</span> <span class="p">{</span> <span class="kr">class</span><span class="o">:</span> <span class="s1">'ActionView::CompiledTemplates'</span><span class="p">,</span>
|
|
178
|
+
<span class="nx">file</span><span class="o">:</span> <span class="s1">'<PWD>/app/views/projects/index.html.erb'</span> <span class="p">},</span>
|
|
179
|
+
<span class="nx">allocations</span> <span class="o">=</span> <span class="p">[</span> <span class="nx">a1</span><span class="p">,</span> <span class="nx">a2</span> <span class="p">],</span>
|
|
180
|
+
<span class="nx">filtered</span> <span class="o">=</span> <span class="nx">filterOutPwd</span><span class="p">(</span><span class="nx">allocations</span><span class="p">);</span>
|
|
181
|
+
|
|
182
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">filtered</span><span class="p">).</span><span class="nx">toEqual</span><span class="p">([</span><span class="nx">a1</span><span class="p">]);</span>
|
|
183
|
+
<span class="p">});</span>
|
|
184
|
+
<span class="p">});</span>
|
|
185
|
+
|
|
186
|
+
<span class="nx">describe</span><span class="p">(</span><span class="s2">"filterOutRuby"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
187
|
+
<span class="nx">it</span><span class="p">(</span><span class="s2">"filters out allocations with a sourcefile in RUBYLIBDIR"</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
|
188
|
+
<span class="kd">var</span> <span class="nx">a1</span> <span class="o">=</span> <span class="p">{</span> <span class="kr">class</span><span class="o">:</span> <span class="s1">'Thread::ConditionVariable'</span><span class="p">,</span>
|
|
189
|
+
<span class="nx">file</span><span class="o">:</span> <span class="s1">'<RUBYLIBDIR>/monitor.rb'</span> <span class="p">},</span>
|
|
190
|
+
<span class="nx">a2</span> <span class="o">=</span> <span class="p">{</span> <span class="kr">class</span><span class="o">:</span> <span class="s1">'ActionView::CompiledTemplates'</span><span class="p">,</span>
|
|
191
|
+
<span class="nx">file</span><span class="o">:</span> <span class="s1">'<PWD>/app/views/projects/index.html.erb'</span> <span class="p">},</span>
|
|
192
|
+
<span class="nx">allocations</span> <span class="o">=</span> <span class="p">[</span> <span class="nx">a1</span><span class="p">,</span> <span class="nx">a2</span> <span class="p">],</span>
|
|
193
|
+
<span class="nx">filtered</span> <span class="o">=</span> <span class="nx">filterOutRuby</span><span class="p">(</span><span class="nx">allocations</span><span class="p">);</span>
|
|
194
|
+
|
|
195
|
+
<span class="nx">expect</span><span class="p">(</span><span class="nx">filtered</span><span class="p">).</span><span class="nx">toEqual</span><span class="p">([</span><span class="nx">a2</span><span class="p">]);</span>
|
|
196
|
+
<span class="p">});</span>
|
|
197
|
+
<span class="p">});</span></pre>
|
|
198
|
+
</div>
|
|
199
|
+
</td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr id="section-5">
|
|
202
|
+
<td class="docs">
|
|
203
|
+
<div class="pilwrap">
|
|
204
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
|
205
|
+
</div>
|
|
206
|
+
<p>Copyright 2013 Google Inc. All Rights Reserved.
|
|
207
|
+
Licensed under the Apache License, Version 2.0, found in the LICENSE file.</p>
|
|
208
|
+
|
|
209
|
+
</td>
|
|
210
|
+
<td class="code">
|
|
211
|
+
<div class="highlight">
|
|
212
|
+
<pre></pre>
|
|
213
|
+
</div>
|
|
214
|
+
</td>
|
|
215
|
+
</tr>
|
|
216
|
+
</tbody>
|
|
217
|
+
</table>
|
|
218
|
+
</div>
|
|
219
|
+
</body>
|
|
220
|
+
</html>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
|
5
|
+
<title>Rack AllocationStats - interactive output specs</title>
|
|
6
|
+
<link href='http://fonts.googleapis.com/css?family=Lora|Istok+Web:700' rel='stylesheet' type='text/css'/>
|
|
7
|
+
<link rel="stylesheet" href="css/docco.css"/>
|
|
8
|
+
<link rel="stylesheet" href="css/jasmine_docco-1.3.1.css"/>
|
|
9
|
+
<link rel="stylesheet" href="js/jasmine.css"/>
|
|
10
|
+
<script src="js/jasmine.js"></script>
|
|
11
|
+
<script src="js/jasmine-html.js"></script>
|
|
12
|
+
<script src="../../lib/rack/allocation_stats/interactive/jquery-2.0.3.min.js"></script>
|
|
13
|
+
<script src="../../lib/rack/allocation_stats/interactive/underscore-min.js"></script>
|
|
14
|
+
<script src="../../lib/rack/allocation_stats/interactive/interactive.js"></script>
|
|
15
|
+
<script src="interactive_spec.js"></script>
|
|
16
|
+
<script>
|
|
17
|
+
(function() {
|
|
18
|
+
var jasmineEnv = jasmine.getEnv();
|
|
19
|
+
jasmineEnv.updateInterval = 250;
|
|
20
|
+
|
|
21
|
+
var htmlReporter = new jasmine.HtmlReporter();
|
|
22
|
+
jasmineEnv.addReporter(htmlReporter);
|
|
23
|
+
|
|
24
|
+
jasmineEnv.specFilter = function(spec) {
|
|
25
|
+
return htmlReporter.specFilter(spec);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var currentWindowOnload = window.onload;
|
|
29
|
+
window.onload = function() {
|
|
30
|
+
if (currentWindowOnload) {
|
|
31
|
+
currentWindowOnload();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
execJasmine();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function execJasmine() {
|
|
38
|
+
jasmineEnv.execute();
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
</script>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<div id="container">
|
|
45
|
+
<div id="background"></div>
|
|
46
|
+
<div class="banner">
|
|
47
|
+
<a href="#">Rack AllocationStats</a>
|
|
48
|
+
</div>
|
|
49
|
+
<table cellspacing="0" cellpadding="0">
|
|
50
|
+
<thead>
|
|
51
|
+
<tr>
|
|
52
|
+
<th class="docs">
|
|
53
|
+
<h1>{{ title }}</h1>
|
|
54
|
+
</th>
|
|
55
|
+
<th class="code"></th>
|
|
56
|
+
</tr>
|
|
57
|
+
</thead>
|
|
58
|
+
<tbody>
|
|
59
|
+
{{#sections}}
|
|
60
|
+
<tr id="section-{{ section_id }}">
|
|
61
|
+
<td class="docs">
|
|
62
|
+
<div class="pilwrap">
|
|
63
|
+
<a class="pilcrow" href="#section-{{ section_id }}">¶</a>
|
|
64
|
+
</div>
|
|
65
|
+
{{{ docs }}}
|
|
66
|
+
</td>
|
|
67
|
+
<td class="code">
|
|
68
|
+
<div class="highlight">
|
|
69
|
+
<pre>{{{ code }}}</pre>
|
|
70
|
+
</div>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
{{/sections}}
|
|
74
|
+
</tbody>
|
|
75
|
+
</table>
|
|
76
|
+
</div>
|
|
77
|
+
</body>
|
|
78
|
+
</html>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
2
|
+
* Licensed under the Apache License, Version 2.0, found in the LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Rack AllocationStats is...
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ## abbreviateClass()
|
|
11
|
+
*
|
|
12
|
+
* `abbreviateClass()` is a method that abbreviates the inside namespaces of a
|
|
13
|
+
* long Ruby class name. Examples:
|
|
14
|
+
*
|
|
15
|
+
* Array => Array
|
|
16
|
+
* Arel::Attributes::Attribute => Arel::...::Attribute
|
|
17
|
+
*/
|
|
18
|
+
describe("abbreviateClass", function() {
|
|
19
|
+
it("leaves classes with < 3 namespaces alone", function() {
|
|
20
|
+
expect(abbreviateClass("Array")).toBe("Array");
|
|
21
|
+
expect(abbreviateClass("File::Stat")).toBe("File::Stat");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("abbreviates classes with > 3 namespaces", function() {
|
|
25
|
+
expect(abbreviateClass("Arel::Attributes::Attribute")).
|
|
26
|
+
toBe('<abbr title="Arel::Attributes::Attribute">Arel::Att…Attribute</abbr>');
|
|
27
|
+
expect(abbreviateClass("ActionDispatch::Routing::RouteSet::Generator")).
|
|
28
|
+
toBe('<abbr title="ActionDispatch::Routing::RouteSet::Generator">ActionDispatch::Rou…Generator</abbr>');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("abbreviates subclasses when >= 3 namespaces", function() {
|
|
32
|
+
expect(abbreviateClass("Array<String>")).toBe("Array<String>");
|
|
33
|
+
expect(abbreviateClass("Array<Fixnum,String>")).toBe("Array<Fixnum,String>");
|
|
34
|
+
expect(abbreviateClass("Array<Arel::Nodes::Equality>")).
|
|
35
|
+
toBe('<abbr title="Array<Arel::Nodes::Equality>">Array<Arel::Nod…Equality></abbr>');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("doesn't abbreviate when only 3 namespaces and middle has < 5 letters", function() {
|
|
39
|
+
expect(abbreviateClass("ActionDispatch::Http::ParameterFilter")).toBe("ActionDispatch::Http::ParameterFilter");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* ## getParameterByName()
|
|
45
|
+
*
|
|
46
|
+
* `getParameterByName()` is a method that grabs a URL parameter from
|
|
47
|
+
* location.search by name. It's amazing this isn't directly available.
|
|
48
|
+
*/
|
|
49
|
+
describe("getParameterByName", function() {
|
|
50
|
+
it("returns blank if parameter not present", function() {
|
|
51
|
+
spyOn(util, "locationSearch").andReturn("?a[b]=c");
|
|
52
|
+
expect(getParameterByName("c")).toBe("");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("returns parameters by name when one parameter is present", function() {
|
|
56
|
+
spyOn(util, "locationSearch").andReturn("?a=b");
|
|
57
|
+
expect(getParameterByName("a")).toBe("b");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("returns parameters by name when one bracketed parameter is present", function() {
|
|
61
|
+
spyOn(util, "locationSearch").andReturn("?a[b]=c");
|
|
62
|
+
expect(getParameterByName("a[b]")).toBe("c");
|
|
63
|
+
expect(getParameterByName("a[c]")).toBe("");
|
|
64
|
+
expect(getParameterByName("a")).toBe("");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("returns parameters by name when multiple parameters are present", function() {
|
|
68
|
+
spyOn(util, "locationSearch").andReturn("?a=b&c=d");
|
|
69
|
+
expect(getParameterByName("a")).toBe("b");
|
|
70
|
+
expect(getParameterByName("c")).toBe("d");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("returns parameters by name when multiple bracketed parameters are present", function() {
|
|
74
|
+
spyOn(util, "locationSearch").andReturn("?a[b]=c&a[d]=e");
|
|
75
|
+
expect(getParameterByName("a[b]")).toBe("c");
|
|
76
|
+
expect(getParameterByName("a[d]")).toBe("e");
|
|
77
|
+
expect(getParameterByName("a[e]")).toBe("");
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("filterOutPwd", function() {
|
|
82
|
+
it("filters out allocations with a sourcefile in PWD", function() {
|
|
83
|
+
var a1 = { class: 'Thread::ConditionVariable',
|
|
84
|
+
file: '<RUBYLIBDIR>/monitor.rb' },
|
|
85
|
+
a2 = { class: 'ActionView::CompiledTemplates',
|
|
86
|
+
file: '<PWD>/app/views/projects/index.html.erb' },
|
|
87
|
+
allocations = [ a1, a2 ],
|
|
88
|
+
filtered = filterOutPwd(allocations);
|
|
89
|
+
|
|
90
|
+
expect(filtered).toEqual([a1]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("filterOutRuby", function() {
|
|
95
|
+
it("filters out allocations with a sourcefile in RUBYLIBDIR", function() {
|
|
96
|
+
var a1 = { class: 'Thread::ConditionVariable',
|
|
97
|
+
file: '<RUBYLIBDIR>/monitor.rb' },
|
|
98
|
+
a2 = { class: 'ActionView::CompiledTemplates',
|
|
99
|
+
file: '<PWD>/app/views/projects/index.html.erb' },
|
|
100
|
+
allocations = [ a1, a2 ],
|
|
101
|
+
filtered = filterOutRuby(allocations);
|
|
102
|
+
|
|
103
|
+
expect(filtered).toEqual([a2]);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Copyright 2013 Google Inc. All Rights Reserved.
|
|
109
|
+
* Licensed under the Apache License, Version 2.0, found in the LICENSE file.
|
|
110
|
+
*/
|
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
jasmine.HtmlReporterHelpers = {};
|
|
2
|
+
|
|
3
|
+
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
|
4
|
+
var el = document.createElement(type);
|
|
5
|
+
|
|
6
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
7
|
+
var child = arguments[i];
|
|
8
|
+
|
|
9
|
+
if (typeof child === 'string') {
|
|
10
|
+
el.appendChild(document.createTextNode(child));
|
|
11
|
+
} else {
|
|
12
|
+
if (child) {
|
|
13
|
+
el.appendChild(child);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (var attr in attrs) {
|
|
19
|
+
if (attr == "className") {
|
|
20
|
+
el[attr] = attrs[attr];
|
|
21
|
+
} else {
|
|
22
|
+
el.setAttribute(attr, attrs[attr]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return el;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
|
30
|
+
var results = child.results();
|
|
31
|
+
var status = results.passed() ? 'passed' : 'failed';
|
|
32
|
+
if (results.skipped) {
|
|
33
|
+
status = 'skipped';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return status;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
|
40
|
+
var parentDiv = this.dom.summary;
|
|
41
|
+
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
|
42
|
+
var parent = child[parentSuite];
|
|
43
|
+
|
|
44
|
+
if (parent) {
|
|
45
|
+
if (typeof this.views.suites[parent.id] == 'undefined') {
|
|
46
|
+
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
|
47
|
+
}
|
|
48
|
+
parentDiv = this.views.suites[parent.id].element;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
parentDiv.appendChild(childElement);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
|
56
|
+
for(var fn in jasmine.HtmlReporterHelpers) {
|
|
57
|
+
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
jasmine.HtmlReporter = function(_doc) {
|
|
62
|
+
var self = this;
|
|
63
|
+
var doc = _doc || window.document;
|
|
64
|
+
|
|
65
|
+
var reporterView;
|
|
66
|
+
|
|
67
|
+
var dom = {};
|
|
68
|
+
|
|
69
|
+
// Jasmine Reporter Public Interface
|
|
70
|
+
self.logRunningSpecs = false;
|
|
71
|
+
|
|
72
|
+
self.reportRunnerStarting = function(runner) {
|
|
73
|
+
var specs = runner.specs() || [];
|
|
74
|
+
|
|
75
|
+
if (specs.length == 0) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
createReporterDom(runner.env.versionString());
|
|
80
|
+
doc.body.appendChild(dom.reporter);
|
|
81
|
+
setExceptionHandling();
|
|
82
|
+
|
|
83
|
+
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
|
84
|
+
reporterView.addSpecs(specs, self.specFilter);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
self.reportRunnerResults = function(runner) {
|
|
88
|
+
reporterView && reporterView.complete();
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
self.reportSuiteResults = function(suite) {
|
|
92
|
+
reporterView.suiteComplete(suite);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
self.reportSpecStarting = function(spec) {
|
|
96
|
+
if (self.logRunningSpecs) {
|
|
97
|
+
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
self.reportSpecResults = function(spec) {
|
|
102
|
+
reporterView.specComplete(spec);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
self.log = function() {
|
|
106
|
+
var console = jasmine.getGlobal().console;
|
|
107
|
+
if (console && console.log) {
|
|
108
|
+
if (console.log.apply) {
|
|
109
|
+
console.log.apply(console, arguments);
|
|
110
|
+
} else {
|
|
111
|
+
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
self.specFilter = function(spec) {
|
|
117
|
+
if (!focusedSpecName()) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return spec.getFullName().indexOf(focusedSpecName()) === 0;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return self;
|
|
125
|
+
|
|
126
|
+
function focusedSpecName() {
|
|
127
|
+
var specName;
|
|
128
|
+
|
|
129
|
+
(function memoizeFocusedSpec() {
|
|
130
|
+
if (specName) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var paramMap = [];
|
|
135
|
+
var params = jasmine.HtmlReporter.parameters(doc);
|
|
136
|
+
|
|
137
|
+
for (var i = 0; i < params.length; i++) {
|
|
138
|
+
var p = params[i].split('=');
|
|
139
|
+
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
specName = paramMap.spec;
|
|
143
|
+
})();
|
|
144
|
+
|
|
145
|
+
return specName;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function createReporterDom(version) {
|
|
149
|
+
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
|
150
|
+
dom.banner = self.createDom('div', { className: 'banner' },
|
|
151
|
+
self.createDom('span', { className: 'title' }, "Jasmine "),
|
|
152
|
+
self.createDom('span', { className: 'version' }, version)),
|
|
153
|
+
|
|
154
|
+
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
|
155
|
+
dom.alert = self.createDom('div', {className: 'alert'},
|
|
156
|
+
self.createDom('span', { className: 'exceptions' },
|
|
157
|
+
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
|
|
158
|
+
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
|
|
159
|
+
dom.results = self.createDom('div', {className: 'results'},
|
|
160
|
+
dom.summary = self.createDom('div', { className: 'summary' }),
|
|
161
|
+
dom.details = self.createDom('div', { id: 'details' }))
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function noTryCatch() {
|
|
166
|
+
return window.location.search.match(/catch=false/);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function searchWithCatch() {
|
|
170
|
+
var params = jasmine.HtmlReporter.parameters(window.document);
|
|
171
|
+
var removed = false;
|
|
172
|
+
var i = 0;
|
|
173
|
+
|
|
174
|
+
while (!removed && i < params.length) {
|
|
175
|
+
if (params[i].match(/catch=/)) {
|
|
176
|
+
params.splice(i, 1);
|
|
177
|
+
removed = true;
|
|
178
|
+
}
|
|
179
|
+
i++;
|
|
180
|
+
}
|
|
181
|
+
if (jasmine.CATCH_EXCEPTIONS) {
|
|
182
|
+
params.push("catch=false");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return params.join("&");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function setExceptionHandling() {
|
|
189
|
+
var chxCatch = document.getElementById('no_try_catch');
|
|
190
|
+
|
|
191
|
+
if (noTryCatch()) {
|
|
192
|
+
chxCatch.setAttribute('checked', true);
|
|
193
|
+
jasmine.CATCH_EXCEPTIONS = false;
|
|
194
|
+
}
|
|
195
|
+
chxCatch.onclick = function() {
|
|
196
|
+
window.location.search = searchWithCatch();
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
jasmine.HtmlReporter.parameters = function(doc) {
|
|
201
|
+
var paramStr = doc.location.search.substring(1);
|
|
202
|
+
var params = [];
|
|
203
|
+
|
|
204
|
+
if (paramStr.length > 0) {
|
|
205
|
+
params = paramStr.split('&');
|
|
206
|
+
}
|
|
207
|
+
return params;
|
|
208
|
+
}
|
|
209
|
+
jasmine.HtmlReporter.sectionLink = function(sectionName) {
|
|
210
|
+
var link = '?';
|
|
211
|
+
var params = [];
|
|
212
|
+
|
|
213
|
+
if (sectionName) {
|
|
214
|
+
params.push('spec=' + encodeURIComponent(sectionName));
|
|
215
|
+
}
|
|
216
|
+
if (!jasmine.CATCH_EXCEPTIONS) {
|
|
217
|
+
params.push("catch=false");
|
|
218
|
+
}
|
|
219
|
+
if (params.length > 0) {
|
|
220
|
+
link += params.join("&");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return link;
|
|
224
|
+
};
|
|
225
|
+
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
|
226
|
+
jasmine.HtmlReporter.ReporterView = function(dom) {
|
|
227
|
+
this.startedAt = new Date();
|
|
228
|
+
this.runningSpecCount = 0;
|
|
229
|
+
this.completeSpecCount = 0;
|
|
230
|
+
this.passedCount = 0;
|
|
231
|
+
this.failedCount = 0;
|
|
232
|
+
this.skippedCount = 0;
|
|
233
|
+
|
|
234
|
+
this.createResultsMenu = function() {
|
|
235
|
+
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
|
236
|
+
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
|
237
|
+
' | ',
|
|
238
|
+
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
|
239
|
+
|
|
240
|
+
this.summaryMenuItem.onclick = function() {
|
|
241
|
+
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
this.detailsMenuItem.onclick = function() {
|
|
245
|
+
showDetails();
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
this.addSpecs = function(specs, specFilter) {
|
|
250
|
+
this.totalSpecCount = specs.length;
|
|
251
|
+
|
|
252
|
+
this.views = {
|
|
253
|
+
specs: {},
|
|
254
|
+
suites: {}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
for (var i = 0; i < specs.length; i++) {
|
|
258
|
+
var spec = specs[i];
|
|
259
|
+
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
|
|
260
|
+
if (specFilter(spec)) {
|
|
261
|
+
this.runningSpecCount++;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
this.specComplete = function(spec) {
|
|
267
|
+
this.completeSpecCount++;
|
|
268
|
+
|
|
269
|
+
if (isUndefined(this.views.specs[spec.id])) {
|
|
270
|
+
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var specView = this.views.specs[spec.id];
|
|
274
|
+
|
|
275
|
+
switch (specView.status()) {
|
|
276
|
+
case 'passed':
|
|
277
|
+
this.passedCount++;
|
|
278
|
+
break;
|
|
279
|
+
|
|
280
|
+
case 'failed':
|
|
281
|
+
this.failedCount++;
|
|
282
|
+
break;
|
|
283
|
+
|
|
284
|
+
case 'skipped':
|
|
285
|
+
this.skippedCount++;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
specView.refresh();
|
|
290
|
+
this.refresh();
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
this.suiteComplete = function(suite) {
|
|
294
|
+
var suiteView = this.views.suites[suite.id];
|
|
295
|
+
if (isUndefined(suiteView)) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
suiteView.refresh();
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
this.refresh = function() {
|
|
302
|
+
|
|
303
|
+
if (isUndefined(this.resultsMenu)) {
|
|
304
|
+
this.createResultsMenu();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// currently running UI
|
|
308
|
+
if (isUndefined(this.runningAlert)) {
|
|
309
|
+
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
|
|
310
|
+
dom.alert.appendChild(this.runningAlert);
|
|
311
|
+
}
|
|
312
|
+
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
|
313
|
+
|
|
314
|
+
// skipped specs UI
|
|
315
|
+
if (isUndefined(this.skippedAlert)) {
|
|
316
|
+
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
|
320
|
+
|
|
321
|
+
if (this.skippedCount === 1 && isDefined(dom.alert)) {
|
|
322
|
+
dom.alert.appendChild(this.skippedAlert);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// passing specs UI
|
|
326
|
+
if (isUndefined(this.passedAlert)) {
|
|
327
|
+
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
|
|
328
|
+
}
|
|
329
|
+
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
|
330
|
+
|
|
331
|
+
// failing specs UI
|
|
332
|
+
if (isUndefined(this.failedAlert)) {
|
|
333
|
+
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
|
|
334
|
+
}
|
|
335
|
+
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
|
|
336
|
+
|
|
337
|
+
if (this.failedCount === 1 && isDefined(dom.alert)) {
|
|
338
|
+
dom.alert.appendChild(this.failedAlert);
|
|
339
|
+
dom.alert.appendChild(this.resultsMenu);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// summary info
|
|
343
|
+
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
|
|
344
|
+
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
this.complete = function() {
|
|
348
|
+
dom.alert.removeChild(this.runningAlert);
|
|
349
|
+
|
|
350
|
+
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
|
351
|
+
|
|
352
|
+
if (this.failedCount === 0) {
|
|
353
|
+
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
|
354
|
+
} else {
|
|
355
|
+
showDetails();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
return this;
|
|
362
|
+
|
|
363
|
+
function showDetails() {
|
|
364
|
+
if (dom.reporter.className.search(/showDetails/) === -1) {
|
|
365
|
+
dom.reporter.className += " showDetails";
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function isUndefined(obj) {
|
|
370
|
+
return typeof obj === 'undefined';
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function isDefined(obj) {
|
|
374
|
+
return !isUndefined(obj);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function specPluralizedFor(count) {
|
|
378
|
+
var str = count + " spec";
|
|
379
|
+
if (count > 1) {
|
|
380
|
+
str += "s"
|
|
381
|
+
}
|
|
382
|
+
return str;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
|
391
|
+
this.spec = spec;
|
|
392
|
+
this.dom = dom;
|
|
393
|
+
this.views = views;
|
|
394
|
+
|
|
395
|
+
this.symbol = this.createDom('li', { className: 'pending' });
|
|
396
|
+
this.dom.symbolSummary.appendChild(this.symbol);
|
|
397
|
+
|
|
398
|
+
this.summary = this.createDom('div', { className: 'specSummary' },
|
|
399
|
+
this.createDom('a', {
|
|
400
|
+
className: 'description',
|
|
401
|
+
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
|
|
402
|
+
title: this.spec.getFullName()
|
|
403
|
+
}, this.spec.description)
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
this.detail = this.createDom('div', { className: 'specDetail' },
|
|
407
|
+
this.createDom('a', {
|
|
408
|
+
className: 'description',
|
|
409
|
+
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
|
410
|
+
title: this.spec.getFullName()
|
|
411
|
+
}, this.spec.getFullName())
|
|
412
|
+
);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
|
416
|
+
return this.getSpecStatus(this.spec);
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
|
420
|
+
this.symbol.className = this.status();
|
|
421
|
+
|
|
422
|
+
switch (this.status()) {
|
|
423
|
+
case 'skipped':
|
|
424
|
+
break;
|
|
425
|
+
|
|
426
|
+
case 'passed':
|
|
427
|
+
this.appendSummaryToSuiteDiv();
|
|
428
|
+
break;
|
|
429
|
+
|
|
430
|
+
case 'failed':
|
|
431
|
+
this.appendSummaryToSuiteDiv();
|
|
432
|
+
this.appendFailureDetail();
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
|
438
|
+
this.summary.className += ' ' + this.status();
|
|
439
|
+
this.appendToSummary(this.spec, this.summary);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
|
443
|
+
this.detail.className += ' ' + this.status();
|
|
444
|
+
|
|
445
|
+
var resultItems = this.spec.results().getItems();
|
|
446
|
+
var messagesDiv = this.createDom('div', { className: 'messages' });
|
|
447
|
+
|
|
448
|
+
for (var i = 0; i < resultItems.length; i++) {
|
|
449
|
+
var result = resultItems[i];
|
|
450
|
+
|
|
451
|
+
if (result.type == 'log') {
|
|
452
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
|
453
|
+
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
|
454
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
|
455
|
+
|
|
456
|
+
if (result.trace.stack) {
|
|
457
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (messagesDiv.childNodes.length > 0) {
|
|
463
|
+
this.detail.appendChild(messagesDiv);
|
|
464
|
+
this.dom.details.appendChild(this.detail);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
|
469
|
+
this.suite = suite;
|
|
470
|
+
this.dom = dom;
|
|
471
|
+
this.views = views;
|
|
472
|
+
|
|
473
|
+
this.element = this.createDom('div', { className: 'suite' },
|
|
474
|
+
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
this.appendToSummary(this.suite, this.element);
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
|
481
|
+
return this.getSpecStatus(this.suite);
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
|
485
|
+
this.element.className += " " + this.status();
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
|
489
|
+
|
|
490
|
+
/* @deprecated Use jasmine.HtmlReporter instead
|
|
491
|
+
*/
|
|
492
|
+
jasmine.TrivialReporter = function(doc) {
|
|
493
|
+
this.document = doc || document;
|
|
494
|
+
this.suiteDivs = {};
|
|
495
|
+
this.logRunningSpecs = false;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
|
499
|
+
var el = document.createElement(type);
|
|
500
|
+
|
|
501
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
502
|
+
var child = arguments[i];
|
|
503
|
+
|
|
504
|
+
if (typeof child === 'string') {
|
|
505
|
+
el.appendChild(document.createTextNode(child));
|
|
506
|
+
} else {
|
|
507
|
+
if (child) { el.appendChild(child); }
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
for (var attr in attrs) {
|
|
512
|
+
if (attr == "className") {
|
|
513
|
+
el[attr] = attrs[attr];
|
|
514
|
+
} else {
|
|
515
|
+
el.setAttribute(attr, attrs[attr]);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return el;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
|
523
|
+
var showPassed, showSkipped;
|
|
524
|
+
|
|
525
|
+
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
|
526
|
+
this.createDom('div', { className: 'banner' },
|
|
527
|
+
this.createDom('div', { className: 'logo' },
|
|
528
|
+
this.createDom('span', { className: 'title' }, "Jasmine"),
|
|
529
|
+
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
|
530
|
+
this.createDom('div', { className: 'options' },
|
|
531
|
+
"Show ",
|
|
532
|
+
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
|
533
|
+
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
|
534
|
+
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
|
535
|
+
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
|
536
|
+
)
|
|
537
|
+
),
|
|
538
|
+
|
|
539
|
+
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
|
540
|
+
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
|
541
|
+
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
|
542
|
+
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
|
543
|
+
);
|
|
544
|
+
|
|
545
|
+
this.document.body.appendChild(this.outerDiv);
|
|
546
|
+
|
|
547
|
+
var suites = runner.suites();
|
|
548
|
+
for (var i = 0; i < suites.length; i++) {
|
|
549
|
+
var suite = suites[i];
|
|
550
|
+
var suiteDiv = this.createDom('div', { className: 'suite' },
|
|
551
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
|
552
|
+
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
|
553
|
+
this.suiteDivs[suite.id] = suiteDiv;
|
|
554
|
+
var parentDiv = this.outerDiv;
|
|
555
|
+
if (suite.parentSuite) {
|
|
556
|
+
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
|
557
|
+
}
|
|
558
|
+
parentDiv.appendChild(suiteDiv);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
this.startedAt = new Date();
|
|
562
|
+
|
|
563
|
+
var self = this;
|
|
564
|
+
showPassed.onclick = function(evt) {
|
|
565
|
+
if (showPassed.checked) {
|
|
566
|
+
self.outerDiv.className += ' show-passed';
|
|
567
|
+
} else {
|
|
568
|
+
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
showSkipped.onclick = function(evt) {
|
|
573
|
+
if (showSkipped.checked) {
|
|
574
|
+
self.outerDiv.className += ' show-skipped';
|
|
575
|
+
} else {
|
|
576
|
+
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
|
582
|
+
var results = runner.results();
|
|
583
|
+
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
|
584
|
+
this.runnerDiv.setAttribute("class", className);
|
|
585
|
+
//do it twice for IE
|
|
586
|
+
this.runnerDiv.setAttribute("className", className);
|
|
587
|
+
var specs = runner.specs();
|
|
588
|
+
var specCount = 0;
|
|
589
|
+
for (var i = 0; i < specs.length; i++) {
|
|
590
|
+
if (this.specFilter(specs[i])) {
|
|
591
|
+
specCount++;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
|
595
|
+
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
|
596
|
+
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
|
597
|
+
|
|
598
|
+
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
|
602
|
+
var results = suite.results();
|
|
603
|
+
var status = results.passed() ? 'passed' : 'failed';
|
|
604
|
+
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
|
605
|
+
status = 'skipped';
|
|
606
|
+
}
|
|
607
|
+
this.suiteDivs[suite.id].className += " " + status;
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
|
611
|
+
if (this.logRunningSpecs) {
|
|
612
|
+
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
|
617
|
+
var results = spec.results();
|
|
618
|
+
var status = results.passed() ? 'passed' : 'failed';
|
|
619
|
+
if (results.skipped) {
|
|
620
|
+
status = 'skipped';
|
|
621
|
+
}
|
|
622
|
+
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
|
623
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
|
624
|
+
this.createDom('a', {
|
|
625
|
+
className: 'description',
|
|
626
|
+
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
|
627
|
+
title: spec.getFullName()
|
|
628
|
+
}, spec.description));
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
var resultItems = results.getItems();
|
|
632
|
+
var messagesDiv = this.createDom('div', { className: 'messages' });
|
|
633
|
+
for (var i = 0; i < resultItems.length; i++) {
|
|
634
|
+
var result = resultItems[i];
|
|
635
|
+
|
|
636
|
+
if (result.type == 'log') {
|
|
637
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
|
638
|
+
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
|
639
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
|
640
|
+
|
|
641
|
+
if (result.trace.stack) {
|
|
642
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (messagesDiv.childNodes.length > 0) {
|
|
648
|
+
specDiv.appendChild(messagesDiv);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
jasmine.TrivialReporter.prototype.log = function() {
|
|
655
|
+
var console = jasmine.getGlobal().console;
|
|
656
|
+
if (console && console.log) {
|
|
657
|
+
if (console.log.apply) {
|
|
658
|
+
console.log.apply(console, arguments);
|
|
659
|
+
} else {
|
|
660
|
+
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
jasmine.TrivialReporter.prototype.getLocation = function() {
|
|
666
|
+
return this.document.location;
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
|
670
|
+
var paramMap = {};
|
|
671
|
+
var params = this.getLocation().search.substring(1).split('&');
|
|
672
|
+
for (var i = 0; i < params.length; i++) {
|
|
673
|
+
var p = params[i].split('=');
|
|
674
|
+
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
if (!paramMap.spec) {
|
|
678
|
+
return true;
|
|
679
|
+
}
|
|
680
|
+
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
|
681
|
+
};
|