closer 0.1.6 → 0.2.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.
- checksums.yaml +4 -4
- data/closer.gemspec +1 -1
- data/lib/closer/formatter/closer.css +6 -16
- data/lib/closer/formatter/closer_html.rb +4 -0
- data/lib/closer/formatter/cucumber.css +8 -6
- data/lib/closer/formatter/html.rb +106 -46
- data/lib/closer/helpers.rb +3 -0
- data/lib/closer/helpers/capture.rb +70 -0
- data/lib/closer/version.rb +1 -1
- data/lib/tasks/close.rake +1 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62426b90fd66e70685392766ccc2729ff35fe0f9
|
4
|
+
data.tar.gz: 6009df630e527185163fe5cab93fcc5fad4ce2d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b3bc50815bc539a9eb99c3f7ce35d9c3774402b4da26cb424b25cba2e306c30719e74c2bab0829d68911622a7270900c4a33a779c2e02101872fc4f2c8cb711
|
7
|
+
data.tar.gz: 3d84bb737b67caf73722e04d2513330fddd1f20e145a6ff8fe6f035057ff97331b0f439e04bd6da46bc7268052bcd65d00b633b2eaaa13a4ad81e9b970c2f0c0
|
data/closer.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.required_ruby_version = '~> 2.0'
|
21
21
|
|
22
|
-
spec.add_runtime_dependency 'cucumber', '~>
|
22
|
+
spec.add_runtime_dependency 'cucumber', '~> 2.0'
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -7,9 +7,11 @@
|
|
7
7
|
font-weight: bold;
|
8
8
|
}
|
9
9
|
|
10
|
-
.cucumber
|
11
|
-
|
12
|
-
|
10
|
+
.cucumber .step.passed table td.skipped {
|
11
|
+
border-left: 1px solid gray;
|
12
|
+
border-bottom: 1px solid gray;
|
13
|
+
background: #FFFFFF;
|
14
|
+
color: #000000;
|
13
15
|
}
|
14
16
|
|
15
17
|
.cucumber ol li.passed,
|
@@ -33,15 +35,6 @@ th ol li.passed,
|
|
33
35
|
background: #F0F8FF;
|
34
36
|
}
|
35
37
|
|
36
|
-
.cucumber ol li.message, td ol li.message, th ol li.message {
|
37
|
-
border-left: 5px solid #999999;
|
38
|
-
border-bottom: 1px solid #999999;
|
39
|
-
background: #F0F8FF;
|
40
|
-
color: #001111;
|
41
|
-
margin: 5px 0px 5px 1.2em;
|
42
|
-
padding: 3px 15px 3px 10px;
|
43
|
-
}
|
44
|
-
|
45
38
|
.feature_dir {
|
46
39
|
font-size: 1.2em;
|
47
40
|
font-weight: bold;
|
@@ -78,9 +71,8 @@ div.contents {
|
|
78
71
|
}
|
79
72
|
|
80
73
|
div.feature .narrative {
|
81
|
-
margin:
|
74
|
+
margin: 10px 21px;
|
82
75
|
line-height: 1.5em;
|
83
|
-
font-size: 1.2em;
|
84
76
|
}
|
85
77
|
|
86
78
|
div.feature .narrative > div {
|
@@ -167,8 +159,6 @@ del.differ {
|
|
167
159
|
background: #ffffff;
|
168
160
|
width: 48%;
|
169
161
|
height: 48%;
|
170
|
-
max-width: 98%;
|
171
|
-
max-height: 98%;
|
172
162
|
cursor: pointer;
|
173
163
|
}
|
174
164
|
|
@@ -151,7 +151,7 @@ body {
|
|
151
151
|
padding: 0px;
|
152
152
|
}
|
153
153
|
.cucumber ol li.step, td ol li.step, th ol li.step {
|
154
|
-
padding: 3px 3px 3px
|
154
|
+
padding: 3px 3px 3px 13px;
|
155
155
|
margin: 5px 0px 5px 5px;
|
156
156
|
}
|
157
157
|
.cucumber ol li, td ol li, th ol li {
|
@@ -166,6 +166,7 @@ body {
|
|
166
166
|
border-bottom: 1px solid #c20000;
|
167
167
|
background: #fffbd3;
|
168
168
|
color: #c20000;
|
169
|
+
padding: 3px 3px 3px 8px;
|
169
170
|
}
|
170
171
|
.cucumber ol li.passed, td ol li.passed, th ol li.passed {
|
171
172
|
border-left: 5px solid #65c400;
|
@@ -192,11 +193,12 @@ body {
|
|
192
193
|
color: #131313;
|
193
194
|
}
|
194
195
|
.cucumber ol li.message, td ol li.message, th ol li.message {
|
195
|
-
border-left: 5px solid
|
196
|
-
border-bottom: 1px solid
|
197
|
-
background: #
|
196
|
+
border-left: 5px solid #999999;
|
197
|
+
border-bottom: 1px solid #999999;
|
198
|
+
background: #F0F8FF;
|
198
199
|
color: #001111;
|
199
|
-
margin
|
200
|
+
margin: 5px 0px 18px 18px;
|
201
|
+
padding: 3px 10px 3px 10px;
|
200
202
|
}
|
201
203
|
.cucumber #summary, td #summary, th #summary {
|
202
204
|
margin: 0px;
|
@@ -282,4 +284,4 @@ body {
|
|
282
284
|
padding: 0.1em 1em 0.2em 0;
|
283
285
|
color: black;
|
284
286
|
background: #fffbd3;
|
285
|
-
}
|
287
|
+
}
|
@@ -1,12 +1,21 @@
|
|
1
1
|
require 'erb'
|
2
|
-
require '
|
2
|
+
require 'builder'
|
3
3
|
require 'cucumber/formatter/duration'
|
4
4
|
require 'cucumber/formatter/io'
|
5
|
+
require 'pathname'
|
5
6
|
require_relative 'closer_html'
|
6
7
|
|
7
8
|
module Closer
|
8
9
|
module Formatter
|
9
10
|
class Html
|
11
|
+
|
12
|
+
# TODO: remove coupling to types
|
13
|
+
AST_CLASSES = {
|
14
|
+
Cucumber::Core::Ast::Scenario => 'scenario',
|
15
|
+
Cucumber::Core::Ast::ScenarioOutline => 'scenario outline'
|
16
|
+
}
|
17
|
+
AST_DATA_TABLE = ::Cucumber::Formatter::LegacyApi::Ast::MultilineArg::DataTable
|
18
|
+
|
10
19
|
include ERB::Util # for the #h method
|
11
20
|
include ::Cucumber::Formatter::Duration
|
12
21
|
include ::Cucumber::Formatter::Io
|
@@ -24,35 +33,55 @@ module Closer
|
|
24
33
|
@header_red = nil
|
25
34
|
@delayed_messages = []
|
26
35
|
@img_id = 0
|
36
|
+
@text_id = 0
|
27
37
|
@inside_outline = false
|
38
|
+
@previous_step_keyword = nil
|
28
39
|
end
|
29
40
|
|
30
41
|
def embed(src, mime_type, label)
|
31
42
|
case(mime_type)
|
32
43
|
when /^image\/(png|gif|jpg|jpeg)/
|
44
|
+
unless File.file?(src) or src =~ /^data:image\/(png|gif|jpg|jpeg);base64,/
|
45
|
+
type = mime_type =~ /;base[0-9]+$/ ? mime_type : mime_type + ";base64"
|
46
|
+
src = "data:" + type + "," + src
|
47
|
+
end
|
33
48
|
embed_image(src, label)
|
49
|
+
when /^text\/plain/
|
50
|
+
embed_text(src, label)
|
34
51
|
end
|
35
52
|
end
|
36
53
|
|
37
54
|
def embed_image(src, label)
|
38
55
|
id = "img_#{@img_id}"
|
39
56
|
@img_id += 1
|
57
|
+
if @io.respond_to?(:path) and File.file?(src)
|
58
|
+
out_dir = Pathname.new(File.dirname(File.absolute_path(@io.path)))
|
59
|
+
src = Pathname.new(File.absolute_path(src)).relative_path_from(out_dir)
|
60
|
+
end
|
40
61
|
@builder.span(:class => 'embed') do |pre|
|
41
62
|
pre << %{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false">#{label}</a><br>
|
42
63
|
<img id="#{id}" style="display: none" src="#{src}"/>}
|
43
64
|
end
|
44
65
|
end
|
45
66
|
|
67
|
+
def embed_text(src, label)
|
68
|
+
id = "text_#{@text_id}"
|
69
|
+
@text_id += 1
|
70
|
+
@builder.span(:class => 'embed') do |pre|
|
71
|
+
pre << %{<a id="#{id}" href="#{src}" title="#{label}">#{label}</a>}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
46
75
|
|
47
76
|
def before_features(features)
|
48
|
-
@step_count = features.step_count
|
77
|
+
@step_count = features && features.step_count || 0 #TODO: Make this work with core!
|
49
78
|
|
50
79
|
@builder.declare!(:DOCTYPE, :html)
|
51
80
|
|
52
81
|
@builder << '<html>'
|
53
82
|
@builder.head do
|
54
83
|
@builder.meta('http-equiv' => 'Content-Type', :content => 'text/html;charset=utf-8')
|
55
|
-
@builder.title 'Cucumber
|
84
|
+
@builder.title 'Cucumber'
|
56
85
|
inline_css
|
57
86
|
inline_js
|
58
87
|
end
|
@@ -67,8 +96,8 @@ module Closer
|
|
67
96
|
@builder.p('',:id => 'totals')
|
68
97
|
@builder.p('',:id => 'duration')
|
69
98
|
@builder.div(:id => 'expand-collapse') do
|
70
|
-
@builder.p('
|
71
|
-
@builder.p('
|
99
|
+
@builder.p('Expand All', :id => 'expander')
|
100
|
+
@builder.p('Collapse All', :id => 'collapser')
|
72
101
|
end
|
73
102
|
end
|
74
103
|
end
|
@@ -156,7 +185,7 @@ module Closer
|
|
156
185
|
|
157
186
|
def background_name(keyword, name, file_colon_line, source_indent)
|
158
187
|
@listing_background = true
|
159
|
-
@builder.h3 do |h3|
|
188
|
+
@builder.h3(:id => "background_#{@scenario_number}") do |h3|
|
160
189
|
@builder.span(keyword, :class => 'keyword')
|
161
190
|
@builder.text!(' ')
|
162
191
|
@builder.span(name, :class => 'val')
|
@@ -166,16 +195,18 @@ module Closer
|
|
166
195
|
def before_feature_element(feature_element)
|
167
196
|
@scenario_number+=1
|
168
197
|
@scenario_red = false
|
169
|
-
css_class =
|
170
|
-
::Cucumber::Ast::Scenario => 'scenario',
|
171
|
-
::Cucumber::Ast::ScenarioOutline => 'scenario outline'
|
172
|
-
}[feature_element.class]
|
198
|
+
css_class = AST_CLASSES[feature_element.class]
|
173
199
|
@builder << "<div class='#{css_class}'>"
|
200
|
+
@in_scenario_outline = feature_element.class == Cucumber::Core::Ast::ScenarioOutline
|
174
201
|
end
|
175
202
|
|
176
203
|
def after_feature_element(feature_element)
|
204
|
+
unless @in_scenario_outline
|
205
|
+
print_messages
|
206
|
+
@builder << '</ol>'
|
207
|
+
end
|
177
208
|
@builder << '</div>'
|
178
|
-
@
|
209
|
+
@in_scenario_outline = nil
|
179
210
|
end
|
180
211
|
|
181
212
|
def scenario_name(keyword, name, file_colon_line, source_indent)
|
@@ -183,14 +214,20 @@ module Closer
|
|
183
214
|
@builder << file_colon_line
|
184
215
|
end
|
185
216
|
@listing_background = false
|
217
|
+
scenario_id = "scenario_#{@scenario_number}"
|
218
|
+
if @inside_outline
|
219
|
+
@outline_row += 1
|
220
|
+
scenario_id += "_#{@outline_row}"
|
221
|
+
@scenario_red = false
|
222
|
+
end
|
186
223
|
|
187
224
|
lines = name.split("\n")
|
188
|
-
@builder.h3 do
|
225
|
+
@builder.h3(:id => scenario_id) do
|
189
226
|
@builder.span(lines[0], :class => 'val')
|
190
227
|
end
|
191
|
-
|
228
|
+
|
192
229
|
if lines.size > 1
|
193
|
-
@builder.
|
230
|
+
@builder.pre(:class => 'narrative', :style => 'display: none;') do
|
194
231
|
@builder << lines[1..-1].join("\n")
|
195
232
|
end
|
196
233
|
end
|
@@ -209,7 +246,7 @@ module Closer
|
|
209
246
|
end
|
210
247
|
|
211
248
|
def before_examples(examples)
|
212
|
-
|
249
|
+
@builder << '<div class="examples">'
|
213
250
|
end
|
214
251
|
|
215
252
|
def after_examples(examples)
|
@@ -229,10 +266,12 @@ module Closer
|
|
229
266
|
end
|
230
267
|
|
231
268
|
def after_steps(steps)
|
232
|
-
|
269
|
+
print_messages
|
270
|
+
@builder << '</ol>' if @in_background or @in_scenario_outline
|
233
271
|
end
|
234
272
|
|
235
273
|
def before_step(step)
|
274
|
+
print_messages
|
236
275
|
@step_id = step.dom_id
|
237
276
|
@step_number += 1
|
238
277
|
@step = step
|
@@ -261,20 +300,24 @@ module Closer
|
|
261
300
|
set_scenario_color(status)
|
262
301
|
|
263
302
|
if ! @delayed_messages.empty? and status == :passed
|
264
|
-
@builder << "<li class='step #{status} expand'>"
|
303
|
+
@builder << "<li id='#{@step_id}' class='step #{status} expand'>"
|
265
304
|
else
|
266
|
-
@builder << "<li class='step #{status}'>"
|
305
|
+
@builder << "<li id='#{@step_id}' class='step #{status}'>"
|
267
306
|
end
|
268
307
|
end
|
269
308
|
|
270
309
|
def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
|
271
310
|
return if @hide_this_step
|
272
311
|
# print snippet for undefined steps
|
312
|
+
unless outline_step?(@step)
|
313
|
+
keyword = @step.actual_keyword(@previous_step_keyword)
|
314
|
+
@previous_step_keyword = keyword
|
315
|
+
end
|
273
316
|
if status == :undefined
|
274
|
-
keyword = @step.actual_keyword if @step.respond_to?(:actual_keyword)
|
275
|
-
step_multiline_class = @step.multiline_arg ? @step.multiline_arg.class : nil
|
276
317
|
@builder.pre do |pre|
|
277
|
-
|
318
|
+
# TODO: snippet text should be an event sent to the formatter so we don't
|
319
|
+
# have this couping to the runtime.
|
320
|
+
pre << @runtime.snippet_text(keyword,step_match.instance_variable_get("@name") || '', @step.multiline_arg)
|
278
321
|
end
|
279
322
|
end
|
280
323
|
@builder << '</li>'
|
@@ -286,7 +329,8 @@ module Closer
|
|
286
329
|
line_index = $2.to_i - 1
|
287
330
|
|
288
331
|
file = $1.force_encoding('UTF-8')
|
289
|
-
File.
|
332
|
+
file = File.join(gem_dir, file) unless File.exist?(file)
|
333
|
+
File.readlines(file)[line_index..-1].each do |line|
|
290
334
|
step_contents << line
|
291
335
|
break if line.chop == 'end' or line.chop.start_with?('end ')
|
292
336
|
end
|
@@ -309,6 +353,7 @@ module Closer
|
|
309
353
|
|
310
354
|
def exception(exception, status)
|
311
355
|
return if @hide_this_step
|
356
|
+
print_messages
|
312
357
|
build_exception_detail(exception)
|
313
358
|
end
|
314
359
|
|
@@ -319,14 +364,14 @@ module Closer
|
|
319
364
|
|
320
365
|
def before_multiline_arg(multiline_arg)
|
321
366
|
return if @hide_this_step || @skip_step
|
322
|
-
if
|
367
|
+
if AST_DATA_TABLE === multiline_arg
|
323
368
|
@builder << '<table>'
|
324
369
|
end
|
325
370
|
end
|
326
371
|
|
327
372
|
def after_multiline_arg(multiline_arg)
|
328
373
|
return if @hide_this_step || @skip_step
|
329
|
-
if
|
374
|
+
if AST_DATA_TABLE === multiline_arg
|
330
375
|
@builder << '</table>'
|
331
376
|
end
|
332
377
|
end
|
@@ -338,7 +383,6 @@ module Closer
|
|
338
383
|
end
|
339
384
|
end
|
340
385
|
|
341
|
-
|
342
386
|
def before_table_row(table_row)
|
343
387
|
@row_id = table_row.dom_id
|
344
388
|
@col_index = 0
|
@@ -401,12 +445,24 @@ module Closer
|
|
401
445
|
end
|
402
446
|
|
403
447
|
def print_table_row_messages
|
448
|
+
return if @delayed_messages.empty?
|
449
|
+
|
450
|
+
@builder.td(:class => 'message') do
|
451
|
+
@builder << @delayed_messages.join(", ")
|
452
|
+
end
|
453
|
+
empty_messages
|
404
454
|
end
|
405
455
|
|
406
456
|
def empty_messages
|
407
457
|
@delayed_messages = []
|
408
458
|
end
|
409
459
|
|
460
|
+
def after_test_case(test_case, result)
|
461
|
+
if result.failed? and not @scenario_red
|
462
|
+
set_scenario_color_failed
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
410
466
|
protected
|
411
467
|
|
412
468
|
def build_exception_detail(exception)
|
@@ -449,26 +505,23 @@ module Closer
|
|
449
505
|
end
|
450
506
|
|
451
507
|
def set_scenario_color_failed
|
452
|
-
id = current_time_string
|
453
|
-
style = 'display: none; margin: 0; padding: 0;'
|
454
|
-
@builder << "<div id=\"#{id}\" style=\"#{style}\"></div>"
|
455
|
-
|
456
508
|
@builder.script do
|
457
509
|
@builder.text!("makeRed('cucumber-header');") unless @header_red
|
458
510
|
@header_red = true
|
459
|
-
@
|
511
|
+
scenario_or_background = @in_background ? "background" : "scenario"
|
512
|
+
@builder.text!("makeRed('#{scenario_or_background}_#{@scenario_number}');") unless @scenario_red
|
460
513
|
@scenario_red = true
|
514
|
+
if @options[:expand] and @inside_outline
|
515
|
+
@builder.text!("makeRed('#{scenario_or_background}_#{@scenario_number}_#{@outline_row}');")
|
516
|
+
end
|
461
517
|
end
|
462
518
|
end
|
463
519
|
|
464
520
|
def set_scenario_color_pending
|
465
|
-
id = current_time_string
|
466
|
-
style = 'display: none; margin: 0; padding: 0;'
|
467
|
-
@builder << "<div id=\"#{id}\" style=\"#{style}\"></div>"
|
468
|
-
|
469
521
|
@builder.script do
|
470
522
|
@builder.text!("makeYellow('cucumber-header');") unless @header_red
|
471
|
-
@
|
523
|
+
scenario_or_background = @in_background ? "background" : "scenario"
|
524
|
+
@builder.text!("makeYellow('#{scenario_or_background}_#{@scenario_number}');") unless @scenario_red
|
472
525
|
end
|
473
526
|
end
|
474
527
|
|
@@ -491,14 +544,14 @@ module Closer
|
|
491
544
|
end
|
492
545
|
end
|
493
546
|
|
494
|
-
step_file = step_match.file_colon_line
|
547
|
+
step_file = step_match.file_colon_line
|
495
548
|
step_file.gsub(/^([^:]*\.rb):(\d*)/) do
|
496
549
|
step_file = "<span style=\"cursor: pointer;\" onclick=\"toggle_step_file(this); return false;\">#{step_file}</span>"
|
497
|
-
end
|
498
550
|
|
499
|
-
|
500
|
-
|
501
|
-
|
551
|
+
@builder.div(:class => 'step_file') do |div|
|
552
|
+
@builder.span do
|
553
|
+
@builder << step_file
|
554
|
+
end
|
502
555
|
end
|
503
556
|
end
|
504
557
|
end
|
@@ -549,7 +602,7 @@ module Closer
|
|
549
602
|
def inline_js_content
|
550
603
|
<<-EOF
|
551
604
|
|
552
|
-
SCENARIOS = "
|
605
|
+
SCENARIOS = "h3[id^='scenario_'],h3[id^=background_]";
|
553
606
|
|
554
607
|
$(document).ready(function() {
|
555
608
|
$(SCENARIOS).css('cursor', 'pointer');
|
@@ -566,7 +619,6 @@ module Closer
|
|
566
619
|
$("#expander").css('cursor', 'pointer');
|
567
620
|
$("#expander").click(function() {
|
568
621
|
$(SCENARIOS).siblings().show();
|
569
|
-
$('li.message').show();
|
570
622
|
});
|
571
623
|
})
|
572
624
|
|
@@ -586,7 +638,7 @@ module Closer
|
|
586
638
|
end
|
587
639
|
|
588
640
|
def move_progress
|
589
|
-
|
641
|
+
#@builder << " <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
|
590
642
|
end
|
591
643
|
|
592
644
|
def percent_done
|
@@ -602,7 +654,7 @@ module Closer
|
|
602
654
|
end
|
603
655
|
|
604
656
|
def backtrace_line(line)
|
605
|
-
line.gsub(
|
657
|
+
line.gsub(/^([^:]*\.(?:rb|feature|haml)):(\d*).*$/) do
|
606
658
|
if ENV['TM_PROJECT_DIRECTORY']
|
607
659
|
"<a href=\"txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}\">#{$1}:#{$2}</a> "
|
608
660
|
else
|
@@ -640,7 +692,11 @@ module Closer
|
|
640
692
|
end
|
641
693
|
|
642
694
|
def create_builder(io)
|
643
|
-
::
|
695
|
+
Builder::XmlMarkup.new(:target => io, :indent => 0)
|
696
|
+
end
|
697
|
+
|
698
|
+
def outline_step?(step)
|
699
|
+
not @step.step.respond_to?(:actual_keyword)
|
644
700
|
end
|
645
701
|
|
646
702
|
class SnippetExtractor #:nodoc:
|
@@ -666,8 +722,12 @@ module Closer
|
|
666
722
|
|
667
723
|
def lines_around(file, line)
|
668
724
|
if File.file?(file)
|
725
|
+
begin
|
669
726
|
lines = File.open(file).read.split("\n")
|
670
|
-
|
727
|
+
rescue ArgumentError
|
728
|
+
return "# Couldn't get snippet for #{file}"
|
729
|
+
end
|
730
|
+
min = [0, line-3].max
|
671
731
|
max = [line+1, lines.length-1].min
|
672
732
|
selected_lines = []
|
673
733
|
selected_lines.join("\n")
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Closer
|
2
|
+
module Helpers
|
3
|
+
module Capture
|
4
|
+
feature_dir = 'features'
|
5
|
+
ARGV.each_with_index do |arg, i|
|
6
|
+
if %w{ -r --require }.include?(arg)
|
7
|
+
feature_dir = ARGV[i + 1]
|
8
|
+
break
|
9
|
+
end
|
10
|
+
end
|
11
|
+
IMAGE_DIR = File.join(feature_dir, 'reports', 'images')
|
12
|
+
FileUtils.mkdir_p(File.basename(IMAGE_DIR))
|
13
|
+
|
14
|
+
@@_screen_count = 0
|
15
|
+
@@_images = []
|
16
|
+
|
17
|
+
def capture(options = {})
|
18
|
+
options ||= {}
|
19
|
+
options = {:title => options} if options.is_a?(String)
|
20
|
+
return if ENV['FORMAT'] == 'junit'
|
21
|
+
|
22
|
+
url = Rack::Utils.unescape(current_url)
|
23
|
+
|
24
|
+
@@_screen_count += 1
|
25
|
+
|
26
|
+
image = File.join(IMAGE_DIR, "#{@@_screen_count}.png")
|
27
|
+
page.driver.save_screenshot(image, :full => true)
|
28
|
+
|
29
|
+
attrs = {
|
30
|
+
:class => 'screenshot',
|
31
|
+
:src => "#{File.basename(IMAGE_DIR)}/#{File.basename(image)}",
|
32
|
+
:title => options[:title],
|
33
|
+
:alt => url
|
34
|
+
}
|
35
|
+
image_tag = "<img #{attrs.map{|k, v| "#{k}=\"#{v}\"" }.join(' ')} />"
|
36
|
+
|
37
|
+
if options[:flash]
|
38
|
+
puts image_tag
|
39
|
+
else
|
40
|
+
@@_images << image_tag
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def resize_window(width, height)
|
45
|
+
case Capybara.current_driver
|
46
|
+
when :poltergeist
|
47
|
+
Capybara.current_session.driver.resize(width, height)
|
48
|
+
when :selenium
|
49
|
+
Capybara.current_session.driver.browser.manage.window.resize_to(width, height)
|
50
|
+
when :webkit
|
51
|
+
# TODO
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def flash_image_tags
|
56
|
+
if @@_images.size > 0
|
57
|
+
puts @@_images.join("\n")
|
58
|
+
@@_images.clear
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
World(Closer::Helpers::Capture)
|
67
|
+
|
68
|
+
AfterStep do |step|
|
69
|
+
flash_image_tags
|
70
|
+
end
|
data/lib/closer/version.rb
CHANGED
data/lib/tasks/close.rake
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: closer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ichy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +74,8 @@ files:
|
|
74
74
|
- lib/closer/formatter/html.rb
|
75
75
|
- lib/closer/formatter/jquery-min.js
|
76
76
|
- lib/closer/formatter/screenshot.js
|
77
|
+
- lib/closer/helpers.rb
|
78
|
+
- lib/closer/helpers/capture.rb
|
77
79
|
- lib/closer/rails/engine.rb
|
78
80
|
- lib/closer/rails/railtie.rb
|
79
81
|
- lib/closer/tasks.rb
|