ananke 1.1.3 → 2.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/lib/sinatra/ananke.rb +181 -0
- data/lib/sinatra/version.rb +3 -0
- metadata +28 -73
- data/Gemfile +0 -15
- data/Rakefile +0 -65
- data/lib/ananke/helpers.rb +0 -85
- data/lib/ananke/linking.rb +0 -35
- data/lib/ananke/routing.rb +0 -159
- data/lib/ananke/serialize.rb +0 -53
- data/lib/ananke/settings.rb +0 -28
- data/lib/ananke/validation.rb +0 -37
- data/lib/ananke.rb +0 -52
- data/lib/version.rb +0 -3
- data/spec/call_chain.rb +0 -23
- data/spec/cov_adapter.rb +0 -9
- data/spec/dumping.rb +0 -15
- data/spec/lib/ananke_spec.rb +0 -178
- data/spec/lib/error_spec.rb +0 -73
- data/spec/lib/json_spec.rb +0 -51
- data/spec/lib/link_to_spec.rb +0 -31
- data/spec/lib/linked_spec.rb +0 -107
- data/spec/lib/out_spec.rb +0 -20
- data/spec/lib/route_for_spec.rb +0 -97
- data/spec/lib/serialize_spec.rb +0 -65
- data/spec/lib/validation_spec.rb +0 -91
- data/spec/nice_formatter.rb +0 -346
- data/spec/spec_helper.rb +0 -27
data/spec/nice_formatter.rb
DELETED
@@ -1,346 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'rspec/core/formatters/base_text_formatter'
|
3
|
-
require 'rspec/core/formatters/snippet_extractor'
|
4
|
-
|
5
|
-
class NiceFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
6
|
-
include ERB::Util # for the #h method
|
7
|
-
|
8
|
-
def method_missing(m, *a, &b)
|
9
|
-
# no-op
|
10
|
-
end
|
11
|
-
|
12
|
-
def message(message)
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(output)
|
16
|
-
super(output)
|
17
|
-
@example_group_number = 0
|
18
|
-
@example_number = 0
|
19
|
-
@header_red = nil
|
20
|
-
end
|
21
|
-
|
22
|
-
# The number of the currently running example_group
|
23
|
-
def example_group_number
|
24
|
-
@example_group_number
|
25
|
-
end
|
26
|
-
|
27
|
-
# The number of the currently running example (a global counter)
|
28
|
-
def example_number
|
29
|
-
@example_number
|
30
|
-
end
|
31
|
-
|
32
|
-
def start(example_count)
|
33
|
-
super(example_count)
|
34
|
-
@output.puts html_header
|
35
|
-
@output.puts report_header
|
36
|
-
@output.flush
|
37
|
-
end
|
38
|
-
|
39
|
-
def example_group_started(example_group)
|
40
|
-
super(example_group)
|
41
|
-
@example_group_red = false
|
42
|
-
@example_group_number += 1
|
43
|
-
unless example_group_number == 1
|
44
|
-
@output.puts " </dl>"
|
45
|
-
@output.puts "</div>"
|
46
|
-
end
|
47
|
-
@output.puts "<div class=\"example_group\">"
|
48
|
-
@output.puts " <dl>"
|
49
|
-
@output.puts " <dt id=\"example_group_#{example_group_number}\">#{example_group.description.gsub(/[\n]/, "<br />")}</dt>"
|
50
|
-
@output.flush
|
51
|
-
end
|
52
|
-
|
53
|
-
def start_dump
|
54
|
-
@output.puts " </dl>"
|
55
|
-
@output.puts "</div>"
|
56
|
-
@output.flush
|
57
|
-
end
|
58
|
-
|
59
|
-
def example_started(example)
|
60
|
-
super(example)
|
61
|
-
@example_number += 1
|
62
|
-
end
|
63
|
-
|
64
|
-
def example_passed(example)
|
65
|
-
move_progress
|
66
|
-
@output.puts " <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{example.description.gsub(/[\n]/, "<br />")}</span></dd>"
|
67
|
-
@output.flush
|
68
|
-
end
|
69
|
-
|
70
|
-
def example_failed(example)
|
71
|
-
counter = 0
|
72
|
-
exception = example.metadata[:execution_result][:exception_encountered]
|
73
|
-
extra = extra_failure_content(exception)
|
74
|
-
failure_style = 'failed'
|
75
|
-
failure_style = RSpec::Core::PendingExampleFixedError === exception ? 'pending_fixed' : 'failed'
|
76
|
-
@output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
|
77
|
-
@header_red = true
|
78
|
-
@output.puts " <script type=\"text/javascript\">makeRed('example_group_#{example_group_number}');</script>" unless @example_group_red
|
79
|
-
@example_group_red = true
|
80
|
-
move_progress
|
81
|
-
@output.puts " <dd class=\"spec #{failure_style}\">"
|
82
|
-
@output.puts " <span class=\"failed_spec_name\">#{h(example.description.gsub(/[\n]/, "<br />"))}</span>"
|
83
|
-
@output.puts " <div class=\"failure\" id=\"failure_#{counter}\">"
|
84
|
-
@output.puts " <div class=\"message\"><pre>#{h(exception.message)}</pre></div>" unless exception.nil?
|
85
|
-
@output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(exception.backtrace, example).join("\n")}</pre></div>" if exception
|
86
|
-
@output.puts extra unless extra == ""
|
87
|
-
@output.puts " </div>"
|
88
|
-
@output.puts " </dd>"
|
89
|
-
@output.flush
|
90
|
-
end
|
91
|
-
|
92
|
-
def example_pending(example)
|
93
|
-
message = example.metadata[:execution_result][:pending_message]
|
94
|
-
@output.puts " <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
|
95
|
-
@output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{example_group_number}');</script>" unless @example_group_red
|
96
|
-
move_progress
|
97
|
-
@output.puts " <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{example.description.gsub(/[\n]/, "<br />")} (PENDING: #{h(message)})</span></dd>"
|
98
|
-
@output.flush
|
99
|
-
end
|
100
|
-
|
101
|
-
# Override this method if you wish to output extra HTML for a failed spec. For example, you
|
102
|
-
# could output links to images or other files produced during the specs.
|
103
|
-
#
|
104
|
-
def extra_failure_content(exception)
|
105
|
-
require 'rspec/core/formatters/snippet_extractor'
|
106
|
-
@snippet_extractor ||= RSpec::Core::Formatters::SnippetExtractor.new
|
107
|
-
" <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(exception)}</code></pre>"
|
108
|
-
end
|
109
|
-
|
110
|
-
def move_progress
|
111
|
-
@output.puts " <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
|
112
|
-
@output.flush
|
113
|
-
end
|
114
|
-
|
115
|
-
def percent_done
|
116
|
-
result = 100.0
|
117
|
-
if @example_count > 0
|
118
|
-
result = ((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
|
119
|
-
end
|
120
|
-
result
|
121
|
-
end
|
122
|
-
|
123
|
-
def dump_failures
|
124
|
-
end
|
125
|
-
|
126
|
-
def dump_pending
|
127
|
-
end
|
128
|
-
|
129
|
-
def dump_summary(duration, example_count, failure_count, pending_count)
|
130
|
-
# TODO - kill dry_run?
|
131
|
-
if dry_run?
|
132
|
-
totals = "This was a dry-run"
|
133
|
-
else
|
134
|
-
totals = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
|
135
|
-
totals << ", #{pending_count} pending" if pending_count > 0
|
136
|
-
end
|
137
|
-
@output.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{duration} seconds</strong>\";</script>"
|
138
|
-
@output.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
|
139
|
-
@output.puts "</div>"
|
140
|
-
@output.puts "</div>"
|
141
|
-
@output.puts "</body>"
|
142
|
-
@output.puts "</html>"
|
143
|
-
@output.flush
|
144
|
-
end
|
145
|
-
|
146
|
-
def html_header
|
147
|
-
<<-EOF
|
148
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
149
|
-
<!DOCTYPE html
|
150
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
151
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
152
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
153
|
-
<head>
|
154
|
-
<title>RSpec results</title>
|
155
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
156
|
-
<meta http-equiv="Expires" content="-1" />
|
157
|
-
<meta http-equiv="Pragma" content="no-cache" />
|
158
|
-
<style type="text/css">
|
159
|
-
body {
|
160
|
-
margin: 0;
|
161
|
-
padding: 0;
|
162
|
-
background: #fff;
|
163
|
-
font-size: 80%;
|
164
|
-
}
|
165
|
-
</style>
|
166
|
-
<script type="text/javascript">
|
167
|
-
// <![CDATA[
|
168
|
-
#{global_scripts}
|
169
|
-
// ]]>
|
170
|
-
</script>
|
171
|
-
<style type="text/css">
|
172
|
-
#{global_styles}
|
173
|
-
</style>
|
174
|
-
</head>
|
175
|
-
<body>
|
176
|
-
EOF
|
177
|
-
end
|
178
|
-
|
179
|
-
def report_header
|
180
|
-
<<-EOF
|
181
|
-
<div class="rspec-report">
|
182
|
-
|
183
|
-
<div id="rspec-header">
|
184
|
-
<div id="label">
|
185
|
-
<h1>RSpec Code Examples</h1>
|
186
|
-
</div>
|
187
|
-
|
188
|
-
<div id="summary">
|
189
|
-
<p id="totals"> </p>
|
190
|
-
<p id="duration"> </p>
|
191
|
-
</div>
|
192
|
-
</div>
|
193
|
-
|
194
|
-
<div class="results">
|
195
|
-
EOF
|
196
|
-
end
|
197
|
-
|
198
|
-
def global_scripts
|
199
|
-
<<-EOF
|
200
|
-
function moveProgressBar(percentDone) {
|
201
|
-
document.getElementById("rspec-header").style.width = percentDone +"%";
|
202
|
-
}
|
203
|
-
function makeRed(element_id) {
|
204
|
-
document.getElementById(element_id).style.background = '#C40D0D';
|
205
|
-
document.getElementById(element_id).style.color = '#FFFFFF';
|
206
|
-
}
|
207
|
-
|
208
|
-
function makeYellow(element_id) {
|
209
|
-
if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
|
210
|
-
{
|
211
|
-
document.getElementById(element_id).style.background = '#FAF834';
|
212
|
-
document.getElementById(element_id).style.color = '#000000';
|
213
|
-
}
|
214
|
-
else
|
215
|
-
{
|
216
|
-
document.getElementById(element_id).style.background = '#FAF834';
|
217
|
-
document.getElementById(element_id).style.color = '#000000';
|
218
|
-
}
|
219
|
-
}
|
220
|
-
EOF
|
221
|
-
end
|
222
|
-
|
223
|
-
def global_styles
|
224
|
-
<<-EOF
|
225
|
-
#rspec-header {
|
226
|
-
background: #65C400; color: #fff; height: 4em;
|
227
|
-
}
|
228
|
-
|
229
|
-
.rspec-report h1 {
|
230
|
-
margin: 0px 10px 0px 10px;
|
231
|
-
padding: 10px;
|
232
|
-
font-family: "Lucida Grande", Helvetica, sans-serif;
|
233
|
-
font-size: 1.8em;
|
234
|
-
position: absolute;
|
235
|
-
}
|
236
|
-
|
237
|
-
#summary {
|
238
|
-
margin: 0; padding: 5px 10px;
|
239
|
-
font-family: "Lucida Grande", Helvetica, sans-serif;
|
240
|
-
text-align: right;
|
241
|
-
top: 0px;
|
242
|
-
right: 0px;
|
243
|
-
float:right;
|
244
|
-
}
|
245
|
-
|
246
|
-
#summary p {
|
247
|
-
margin: 0 0 0 2px;
|
248
|
-
}
|
249
|
-
|
250
|
-
#summary #totals {
|
251
|
-
font-size: 1.2em;
|
252
|
-
}
|
253
|
-
|
254
|
-
.example_group {
|
255
|
-
margin: 0 10px 5px;
|
256
|
-
background: #fff;
|
257
|
-
}
|
258
|
-
|
259
|
-
dl {
|
260
|
-
margin: 0; padding: 0 0 5px;
|
261
|
-
font: normal 11px "Lucida Grande", Helvetica, sans-serif;
|
262
|
-
}
|
263
|
-
|
264
|
-
dt {
|
265
|
-
padding: 3px;
|
266
|
-
background: #65C400;
|
267
|
-
color: #fff;
|
268
|
-
font-weight: bold;
|
269
|
-
}
|
270
|
-
|
271
|
-
dd {
|
272
|
-
margin: 5px 0 5px 5px;
|
273
|
-
padding: 3px 3px 3px 18px;
|
274
|
-
}
|
275
|
-
|
276
|
-
dd.spec.passed {
|
277
|
-
border-left: 5px solid #65C400;
|
278
|
-
border-bottom: 1px solid #65C400;
|
279
|
-
background: #DBFFB4; color: #3D7700;
|
280
|
-
}
|
281
|
-
|
282
|
-
dd.spec.failed {
|
283
|
-
border-left: 5px solid #C20000;
|
284
|
-
border-bottom: 1px solid #C20000;
|
285
|
-
color: #C20000; background: #FFFBD3;
|
286
|
-
}
|
287
|
-
|
288
|
-
dd.spec.not_implemented {
|
289
|
-
border-left: 5px solid #FAF834;
|
290
|
-
border-bottom: 1px solid #FAF834;
|
291
|
-
background: #FCFB98; color: #131313;
|
292
|
-
}
|
293
|
-
|
294
|
-
dd.spec.pending_fixed {
|
295
|
-
border-left: 5px solid #0000C2;
|
296
|
-
border-bottom: 1px solid #0000C2;
|
297
|
-
color: #0000C2; background: #D3FBFF;
|
298
|
-
}
|
299
|
-
|
300
|
-
.backtrace {
|
301
|
-
color: #000;
|
302
|
-
font-size: 12px;
|
303
|
-
}
|
304
|
-
|
305
|
-
a {
|
306
|
-
color: #BE5C00;
|
307
|
-
}
|
308
|
-
|
309
|
-
/* Ruby code, style similar to vibrant ink */
|
310
|
-
.ruby {
|
311
|
-
font-size: 12px;
|
312
|
-
font-family: monospace;
|
313
|
-
color: white;
|
314
|
-
background-color: black;
|
315
|
-
padding: 0.1em 0 0.2em 0;
|
316
|
-
}
|
317
|
-
|
318
|
-
.ruby .keyword { color: #FF6600; }
|
319
|
-
.ruby .constant { color: #339999; }
|
320
|
-
.ruby .attribute { color: white; }
|
321
|
-
.ruby .global { color: white; }
|
322
|
-
.ruby .module { color: white; }
|
323
|
-
.ruby .class { color: white; }
|
324
|
-
.ruby .string { color: #66FF00; }
|
325
|
-
.ruby .ident { color: white; }
|
326
|
-
.ruby .method { color: #FFCC00; }
|
327
|
-
.ruby .number { color: white; }
|
328
|
-
.ruby .char { color: white; }
|
329
|
-
.ruby .comment { color: #9933CC; }
|
330
|
-
.ruby .symbol { color: white; }
|
331
|
-
.ruby .regex { color: #44B4CC; }
|
332
|
-
.ruby .punct { color: white; }
|
333
|
-
.ruby .escape { color: white; }
|
334
|
-
.ruby .interp { color: white; }
|
335
|
-
.ruby .expr { color: white; }
|
336
|
-
|
337
|
-
.ruby .offending { background-color: gray; }
|
338
|
-
.ruby .linenum {
|
339
|
-
width: 75px;
|
340
|
-
padding: 0.1em 1em 0.2em 0;
|
341
|
-
color: #000000;
|
342
|
-
background-color: #FFFBD3;
|
343
|
-
}
|
344
|
-
EOF
|
345
|
-
end
|
346
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#=========================CODE COVERAGE========================
|
2
|
-
require './spec/cov_adapter'
|
3
|
-
SimpleCov.start 'cov'
|
4
|
-
|
5
|
-
#===========================REQUIRES===========================
|
6
|
-
require 'colored'
|
7
|
-
require 'json'
|
8
|
-
require 'rack'
|
9
|
-
require 'rspec'
|
10
|
-
require 'rack/test'
|
11
|
-
require './lib/ananke'
|
12
|
-
|
13
|
-
extend Colored
|
14
|
-
|
15
|
-
#==================SETUP TEST ENVIRONMENT======================
|
16
|
-
ENV['RACK_ENV'] = 'test'
|
17
|
-
|
18
|
-
Ananke.set :output, false
|
19
|
-
Ananke.set :info, true
|
20
|
-
Ananke.set :warning, true
|
21
|
-
Ananke.set :error, true
|
22
|
-
|
23
|
-
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
24
|
-
|
25
|
-
#==================FOR DUMPING HTTP REQUESTS===================
|
26
|
-
require './spec/dumping'
|
27
|
-
clear_dump
|