lazyman 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
data/lazyman.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "lazyman"
8
- s.version = "0.1.8"
8
+ s.version = "0.1.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["easonhan"]
12
- s.date = "2013-04-21"
12
+ s.date = "2013-05-06"
13
13
  s.description = "A test framework using watir-webdriver rspec and page-object"
14
14
  s.email = "nbkhic@qq.com"
15
15
  s.executables = ["lazyman"]
@@ -1,462 +1,24 @@
1
1
  require 'erb'
2
- require 'rspec/core/formatters/base_text_formatter'
2
+ require 'rspec/core/formatters/html_formatter'
3
3
 
4
4
  module Lazyman
5
- class LazymanFormatter < ::RSpec::Core::Formatters::BaseTextFormatter
6
- include ERB::Util # for the #h method
7
-
5
+ class LazymanFormatter < ::RSpec::Core::Formatters::HtmlFormatter
8
6
  def initialize(output)
9
7
  output = File.new(File.expand_path(File.join('.', 'app', 'reports', "#{Time.now.strftime("%Y%m%d_%H%M%S")}.html")), 'w')
10
8
  super(output)
11
- @example_group_number = 0
12
- @example_number = 0
13
- @header_red = nil
14
- end
15
-
16
- private
17
- def method_missing(m, *a, &b)
18
- # no-op
19
- end
20
-
21
- public
22
- def message(message)
23
- end
24
-
25
- # The number of the currently running example_group
26
- def example_group_number
27
- @example_group_number
28
- end
29
-
30
- # The number of the currently running example (a global counter)
31
- def example_number
32
- @example_number
33
- end
34
-
35
- def start(example_count)
36
- super(example_count)
37
- @output.puts html_header
38
- @output.puts report_header
39
- @output.flush
40
- end
41
-
42
- def example_group_started(example_group)
43
- super(example_group)
44
- @example_group_red = false
45
- @example_group_number += 1
46
- unless example_group_number == 1
47
- @output.puts " </dl>"
48
- @output.puts "</div>"
49
- end
50
- @output.puts "<div id=\"div_group_#{example_group_number}\" class=\"example_group passed\">"
51
- @output.puts " <dl #{current_indentation}>"
52
- @output.puts " <dt id=\"example_group_#{example_group_number}\" class=\"passed\">#{h(example_group.description)}</dt>"
53
- @output.flush
54
- end
55
-
56
- def start_dump
57
- @output.puts " </dl>"
58
- @output.puts "</div>"
59
- @output.flush
60
- end
61
-
62
- def example_started(example)
63
- super(example)
64
- @example_number += 1
65
- end
66
-
67
- def example_passed(example)
68
- move_progress
69
- @output.puts " <dd class=\"example passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span><span class='duration'>#{sprintf("%.5f", example.execution_result[:run_time])}s</span></dd>"
70
- @output.flush
9
+ @printer.class.send(:define_method, 'puts') do |what|
10
+ @output.puts what
11
+ end #define_method
71
12
  end
72
13
 
73
14
  def example_failed(example)
74
15
  super(example)
75
- exception = example.metadata[:execution_result][:exception]
76
- extra = extra_failure_content(exception)
77
- @output.puts " <script type=\"text/javascript\">makeRed('lazyman-header');</script>" unless @header_red
78
- @header_red = true
79
- @output.puts " <script type=\"text/javascript\">makeRed('div_group_#{example_group_number}');</script>" unless @example_group_red
80
- @output.puts " <script type=\"text/javascript\">makeRed('example_group_#{example_group_number}');</script>" unless @example_group_red
81
- @example_group_red = true
82
- move_progress
83
- @output.puts " <dd class=\"example #{exception.pending_fixed? ? 'pending_fixed' : 'failed'}\">"
84
- @output.puts " <span class=\"failed_spec_name\">#{h(example.description)}</span>"
85
- @output.puts " <span class=\"duration\">#{sprintf('%.5f', example.execution_result[:run_time])}s</span>"
86
- @output.puts " <div class=\"failure\" id=\"failure_#{@failed_examples.size}\">"
87
- @output.puts " <div class=\"message\"><pre>#{h(exception.message)}</pre></div>" unless exception.nil?
88
- @output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(exception.backtrace, example).join("\n")}</pre></div>" if exception
89
- @output.puts extra unless extra == ""
90
- @output.puts "<a href=\"#{$navi.url}\">#{$navi.url}</a>" if $navi
91
- @output.puts " </div>"
92
- @output.puts " </dd>"
93
- @output.flush
94
- end
95
-
96
- def example_pending(example)
97
- message = example.metadata[:execution_result][:pending_message]
98
- @output.puts " <script type=\"text/javascript\">makeYellow('lazyman-header');</script>" unless @header_red
99
- @output.puts " <script type=\"text/javascript\">makeYellow('div_group_#{example_group_number}');</script>" unless @example_group_red
100
- @output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{example_group_number}');</script>" unless @example_group_red
101
- move_progress
102
- @output.puts " <dd class=\"example not_implemented\"><span class=\"not_implemented_spec_name\">#{h(example.description)} (PENDING: #{h(message)})</span></dd>"
103
- @output.flush
104
- end
105
-
106
- # Override this method if you wish to output extra HTML for a failed spec. For example, you
107
- # could output links to images or other files produced during the specs.
108
- #
109
- def extra_failure_content(exception)
110
- require 'rspec/core/formatters/snippet_extractor'
111
- backtrace = exception.backtrace.map {|line| backtrace_line(line)}
112
- backtrace.compact!
113
- @snippet_extractor ||= ::RSpec::Core::Formatters::SnippetExtractor.new
114
- " <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
115
- end
116
-
117
- def move_progress
118
- @output.puts " <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
119
- @output.flush
120
- end
121
-
122
- def percent_done
123
- result = 100.0
124
- if @example_count > 0
125
- result = ((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
126
- end
127
- result
128
- end
129
-
130
- def dump_failures
131
- end
132
-
133
- def dump_pending
134
- end
135
-
136
- def dump_summary(duration, example_count, failure_count, pending_count)
137
- # TODO - kill dry_run?
138
- if dry_run?
139
- totals = "This was a dry-run"
140
- else
141
- totals = "#{example_count} example#{'s' unless example_count == 1}, "
142
- totals << "#{failure_count} failure#{'s' unless failure_count == 1}"
143
- totals << ", #{pending_count} pending" if pending_count > 0
144
- end
145
- @output.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{sprintf("%.5f", duration)} seconds</strong>\";</script>"
146
- @output.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
147
- @output.puts "</div>"
148
- @output.puts "</div>"
149
- @output.puts "</body>"
150
- @output.puts "</html>"
151
- @output.flush
152
- end
153
-
154
- def current_indentation
155
- "style=\"margin-left: #{(example_group.ancestors.size - 1) * 15}px;\""
156
- end
157
-
158
- def html_header
159
- <<-EOF
160
- <?xml version="1.0" encoding="UTF-8"?>
161
- <!DOCTYPE html
162
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
163
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
164
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
165
- <head>
166
- <title>Lazyman Report</title>
167
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
168
- <meta http-equiv="Expires" content="-1" />
169
- <meta http-equiv="Pragma" content="no-cache" />
170
- <style type="text/css">
171
- body {
172
- margin: 0;
173
- padding: 0;
174
- background: #fff;
175
- font-size: 80%;
176
- }
177
- </style>
178
- <script type="text/javascript">
179
- // <![CDATA[
180
- #{global_scripts}
181
- // ]]>
182
- </script>
183
- <style type="text/css">
184
- #{global_styles}
185
- </style>
186
- </head>
187
- <body>
188
- EOF
189
- end
190
-
191
- def report_header
192
- <<-EOF
193
- <div class="lazyman-report">
194
-
195
- <div id="lazyman-header">
196
- <div id="label">
197
- <h1>Lazyman Report</h1>
198
- </div>
199
-
200
- <div id="display-filters">
201
- <input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked onchange="apply_filters()" value="1"> <label for="passed_checkbox">Passed</label>
202
- <input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked onchange="apply_filters()" value="2"> <label for="failed_checkbox">Failed</label>
203
- <input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked onchange="apply_filters()" value="3"> <label for="pending_checkbox">Pending</label>
204
- </div>
205
-
206
- <div id="summary">
207
- <p id="totals">&nbsp;</p>
208
- <p id="duration">&nbsp;</p>
209
- </div>
210
- </div>
211
-
212
-
213
- <div class="results">
214
- EOF
215
- end
216
-
217
- def global_scripts
218
- <<-EOF
219
-
220
- function addClass(element_id, classname) {
221
- document.getElementById(element_id).className += (" " + classname);
222
- }
223
-
224
- function removeClass(element_id, classname) {
225
- var elem = document.getElementById(element_id);
226
- var classlist = elem.className.replace(classname,'');
227
- elem.className = classlist;
228
- }
229
-
230
- function moveProgressBar(percentDone) {
231
- document.getElementById("lazyman-header").style.width = percentDone +"%";
232
- }
233
-
234
- function makeRed(element_id) {
235
- removeClass(element_id, 'passed');
236
- removeClass(element_id, 'not_implemented');
237
- addClass(element_id,'failed');
238
- }
239
-
240
- function makeYellow(element_id) {
241
- var elem = document.getElementById(element_id);
242
- if (elem.className.indexOf("failed") == -1) { // class doesn't includes failed
243
- if (elem.className.indexOf("not_implemented") == -1) { // class doesn't include not_implemented
244
- removeClass(element_id, 'passed');
245
- addClass(element_id,'not_implemented');
246
- }
247
- }
248
- }
249
-
250
- function apply_filters() {
251
- var passed_filter = document.getElementById('passed_checkbox').checked;
252
- var failed_filter = document.getElementById('failed_checkbox').checked;
253
- var pending_filter = document.getElementById('pending_checkbox').checked;
254
-
255
- assign_display_style("example passed", passed_filter);
256
- assign_display_style("example failed", failed_filter);
257
- assign_display_style("example not_implemented", pending_filter);
258
-
259
- assign_display_style_for_group("example_group passed", passed_filter);
260
- assign_display_style_for_group("example_group not_implemented", pending_filter, pending_filter || passed_filter);
261
- assign_display_style_for_group("example_group failed", failed_filter, failed_filter || pending_filter || passed_filter);
262
- }
263
-
264
- function get_display_style(display_flag) {
265
- var style_mode = 'none';
266
- if (display_flag == true) {
267
- style_mode = 'block';
268
- }
269
- return style_mode;
270
- }
271
-
272
- function assign_display_style(classname, display_flag) {
273
- var style_mode = get_display_style(display_flag);
274
- var elems = document.getElementsByClassName(classname)
275
- for (var i=0; i<elems.length;i++) {
276
- elems[i].style.display = style_mode;
277
- }
278
- }
279
-
280
- function assign_display_style_for_group(classname, display_flag, subgroup_flag) {
281
- var display_style_mode = get_display_style(display_flag);
282
- var subgroup_style_mode = get_display_style(subgroup_flag);
283
- var elems = document.getElementsByClassName(classname)
284
- for (var i=0; i<elems.length;i++) {
285
- var style_mode = display_style_mode;
286
- if ((display_flag != subgroup_flag) && (elems[i].getElementsByTagName('dt')[0].innerHTML.indexOf(", ") != -1)) {
287
- elems[i].style.display = subgroup_style_mode;
288
- } else {
289
- elems[i].style.display = display_style_mode;
290
- }
291
- }
292
- }
293
- EOF
294
- end
295
-
296
- def global_styles
297
- <<-EOF
298
- #lazyman-header {
299
- background: #65C400; color: #fff; height: 4em;
300
- }
301
-
302
- .lazyman-report h1 {
303
- margin: 0px 10px 0px 10px;
304
- padding: 10px;
305
- font-family: "Lucida Grande", Helvetica, sans-serif;
306
- font-size: 1.8em;
307
- position: absolute;
308
- }
309
-
310
- #label {
311
- float:left;
312
- }
313
-
314
- #display-filters {
315
- float:left;
316
- padding: 28px 0 0 40%;
317
- font-family: "Lucida Grande", Helvetica, sans-serif;
318
- }
319
-
320
- #summary {
321
- float:right;
322
- padding: 5px 10px;
323
- font-family: "Lucida Grande", Helvetica, sans-serif;
324
- text-align: right;
325
- }
326
-
327
- #summary p {
328
- margin: 0 0 0 2px;
329
- }
330
-
331
- #summary #totals {
332
- font-size: 1.2em;
333
- }
334
-
335
- .example_group {
336
- margin: 0 10px 5px;
337
- background: #fff;
338
- }
339
-
340
- dl {
341
- margin: 0; padding: 0 0 5px;
342
- font: normal 11px "Lucida Grande", Helvetica, sans-serif;
343
- }
344
-
345
- dt {
346
- padding: 3px;
347
- background: #65C400;
348
- color: #fff;
349
- font-weight: bold;
350
- }
351
-
352
- dd {
353
- margin: 5px 0 5px 5px;
354
- padding: 3px 3px 3px 18px;
355
- }
356
-
357
- dd .duration {
358
- padding-left: 5px;
359
- text-align: right;
360
- right: 0px;
361
- float:right;
362
- }
363
-
364
- dd.example.passed {
365
- border-left: 5px solid #65C400;
366
- border-bottom: 1px solid #65C400;
367
- background: #DBFFB4; color: #3D7700;
368
- }
369
-
370
- dd.example.not_implemented {
371
- border-left: 5px solid #FAF834;
372
- border-bottom: 1px solid #FAF834;
373
- background: #FCFB98; color: #131313;
374
- }
375
-
376
- dd.example.pending_fixed {
377
- border-left: 5px solid #0000C2;
378
- border-bottom: 1px solid #0000C2;
379
- color: #0000C2; background: #D3FBFF;
380
- }
381
-
382
- dd.example.failed {
383
- border-left: 5px solid #C20000;
384
- border-bottom: 1px solid #C20000;
385
- color: #C20000; background: #FFFBD3;
386
- }
387
-
388
-
389
- dt.not_implemented {
390
- color: #000000; background: #FAF834;
391
- }
392
-
393
- dt.pending_fixed {
394
- color: #FFFFFF; background: #C40D0D;
395
- }
396
-
397
- dt.failed {
398
- color: #FFFFFF; background: #C40D0D;
399
- }
400
-
401
-
402
- #lazyman-header.not_implemented {
403
- color: #000000; background: #FAF834;
404
- }
405
-
406
- #lazyman-header.pending_fixed {
407
- color: #FFFFFF; background: #C40D0D;
408
- }
409
-
410
- #lazyman-header.failed {
411
- color: #FFFFFF; background: #C40D0D;
412
- }
413
-
414
-
415
- .backtrace {
416
- color: #000;
417
- font-size: 12px;
418
- }
419
-
420
- a {
421
- color: #BE5C00;
422
- }
423
-
424
- /* Ruby code, style similar to vibrant ink */
425
- .ruby {
426
- font-size: 12px;
427
- font-family: monospace;
428
- color: white;
429
- background-color: black;
430
- padding: 0.1em 0 0.2em 0;
431
- }
432
-
433
- .ruby .keyword { color: #FF6600; }
434
- .ruby .constant { color: #339999; }
435
- .ruby .attribute { color: white; }
436
- .ruby .global { color: white; }
437
- .ruby .module { color: white; }
438
- .ruby .class { color: white; }
439
- .ruby .string { color: #66FF00; }
440
- .ruby .ident { color: white; }
441
- .ruby .method { color: #FFCC00; }
442
- .ruby .number { color: white; }
443
- .ruby .char { color: white; }
444
- .ruby .comment { color: #9933CC; }
445
- .ruby .symbol { color: white; }
446
- .ruby .regex { color: #44B4CC; }
447
- .ruby .punct { color: white; }
448
- .ruby .escape { color: white; }
449
- .ruby .interp { color: white; }
450
- .ruby .expr { color: white; }
451
-
452
- .ruby .offending { background-color: gray; }
453
- .ruby .linenum {
454
- width: 75px;
455
- padding: 0.1em 1em 0.2em 0;
456
- color: #000000;
457
- background-color: #FFFBD3;
458
- }
459
- EOF
460
- end
461
- end
462
- end
16
+ if $navi
17
+ failed_url = $navi.url rescue $navi.current_url
18
+ @printer.puts "<a target=\"_blank\" href=\"#{failed_url}\">failed url is [#{failed_url}]</a>"
19
+ @printer.puts '<br />'
20
+ @printer.flush
21
+ end #if
22
+ end
23
+ end #LazymanFormatter
24
+ end #Lazyman
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazyman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-21 00:00:00.000000000 Z
12
+ date: 2013-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &23800728 !ruby/object:Gem::Requirement
16
+ requirement: &23525952 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.13.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *23800728
24
+ version_requirements: *23525952
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: page-object
27
- requirement: &23800440 !ruby/object:Gem::Requirement
27
+ requirement: &23525664 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.6.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *23800440
35
+ version_requirements: *23525664
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: thor
38
- requirement: &23800152 !ruby/object:Gem::Requirement
38
+ requirement: &23525376 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.14.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *23800152
46
+ version_requirements: *23525376
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: active_support
49
- requirement: &23799864 !ruby/object:Gem::Requirement
49
+ requirement: &23525088 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 3.0.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *23799864
57
+ version_requirements: *23525088
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rdoc
60
- requirement: &23799576 !ruby/object:Gem::Requirement
60
+ requirement: &23524800 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '3.12'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *23799576
68
+ version_requirements: *23524800
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &23799288 !ruby/object:Gem::Requirement
71
+ requirement: &23524512 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *23799288
79
+ version_requirements: *23524512
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &23799000 !ruby/object:Gem::Requirement
82
+ requirement: &23524224 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.8.4
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *23799000
90
+ version_requirements: *23524224
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &23798712 !ruby/object:Gem::Requirement
93
+ requirement: &23523936 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 2.13.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *23798712
101
+ version_requirements: *23523936
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: page-object
104
- requirement: &23798424 !ruby/object:Gem::Requirement
104
+ requirement: &23523648 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.8.6.1
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *23798424
112
+ version_requirements: *23523648
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: thor
115
- requirement: &23798136 !ruby/object:Gem::Requirement
115
+ requirement: &23523360 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.14.6
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *23798136
123
+ version_requirements: *23523360
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: active_support
126
- requirement: &23797848 !ruby/object:Gem::Requirement
126
+ requirement: &23523072 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: 3.0.0
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *23797848
134
+ version_requirements: *23523072
135
135
  description: A test framework using watir-webdriver rspec and page-object
136
136
  email: nbkhic@qq.com
137
137
  executables:
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  segments:
220
220
  - 0
221
- hash: -650974257
221
+ hash: -461763587
222
222
  required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  none: false
224
224
  requirements: