cucumber 0.8.5 → 0.8.6
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/.rspec +1 -1
- data/LICENSE +1 -1
- data/Rakefile +5 -51
- data/bin/cucumber +7 -1
- data/cucumber.gemspec +463 -679
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +4 -7
- data/examples/i18n/ru/features/division.feature +2 -2
- data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
- data/examples/sinatra/features/support/env.rb +2 -5
- data/examples/v8/features/fibonacci.feature +1 -1
- data/examples/watir/features/step_definitions/search_steps.rb +1 -1
- data/features/background.feature +284 -95
- data/features/custom_formatter.feature +3 -73
- data/features/json_formatter.feature +160 -245
- data/features/step_definitions/cucumber_steps.rb +7 -153
- data/features/support/env.rb +18 -140
- data/fixtures/junit/features/pending.feature +3 -1
- data/fixtures/self_test/features/support/env.rb +8 -0
- data/fixtures/tickets/features.html +1 -1
- data/gem_tasks/examples.rake +1 -1
- data/lib/cucumber.rb +12 -0
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +21 -5
- data/lib/cucumber/ast/examples.rb +12 -4
- data/lib/cucumber/ast/feature.rb +13 -5
- data/lib/cucumber/ast/feature_element.rb +9 -4
- data/lib/cucumber/ast/outline_table.rb +4 -4
- data/lib/cucumber/ast/scenario.rb +7 -5
- data/lib/cucumber/ast/scenario_outline.rb +23 -15
- data/lib/cucumber/ast/step.rb +5 -0
- data/lib/cucumber/ast/step_invocation.rb +21 -15
- data/lib/cucumber/ast/table.rb +14 -8
- data/lib/cucumber/ast/tree_walker.rb +10 -48
- data/lib/cucumber/cli/configuration.rb +33 -8
- data/lib/cucumber/cli/main.rb +20 -35
- data/lib/cucumber/cli/options.rb +8 -7
- data/lib/cucumber/cli/profile_loader.rb +2 -0
- data/lib/cucumber/core_ext/proc.rb +2 -1
- data/lib/cucumber/feature_file.rb +47 -15
- data/lib/cucumber/formatter/ansicolor.rb +3 -5
- data/lib/cucumber/formatter/console.rb +27 -23
- data/lib/cucumber/formatter/cucumber.css +34 -17
- data/lib/cucumber/formatter/cucumber.sass +173 -182
- data/lib/cucumber/formatter/html.rb +46 -11
- data/lib/cucumber/formatter/io.rb +2 -4
- data/lib/cucumber/formatter/json.rb +15 -152
- data/lib/cucumber/formatter/json_pretty.rb +5 -6
- data/lib/cucumber/formatter/junit.rb +28 -22
- data/lib/cucumber/formatter/pdf.rb +6 -6
- data/lib/cucumber/formatter/pretty.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +22 -11
- data/lib/cucumber/formatter/unicode.rb +41 -20
- data/lib/cucumber/js_support/js_dsl.js +4 -4
- data/lib/cucumber/js_support/js_language.rb +9 -5
- data/lib/cucumber/js_support/js_snippets.rb +2 -2
- data/lib/cucumber/language_support.rb +2 -2
- data/lib/cucumber/parser/gherkin_builder.rb +35 -30
- data/lib/cucumber/platform.rb +8 -8
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +80 -31
- data/lib/cucumber/rb_support/rb_dsl.rb +1 -0
- data/lib/cucumber/rb_support/rb_language.rb +10 -8
- data/lib/cucumber/rb_support/rb_step_definition.rb +8 -0
- data/lib/cucumber/rb_support/rb_transform.rb +17 -0
- data/lib/cucumber/rb_support/rb_world.rb +26 -18
- data/lib/cucumber/rspec/doubles.rb +3 -3
- data/lib/cucumber/step_match.rb +6 -2
- data/lib/cucumber/step_mother.rb +6 -427
- data/lib/cucumber/wire_support/configuration.rb +4 -1
- data/lib/cucumber/wire_support/wire_language.rb +3 -10
- data/spec/cucumber/ast/background_spec.rb +68 -6
- data/spec/cucumber/ast/feature_factory.rb +5 -4
- data/spec/cucumber/ast/feature_spec.rb +4 -4
- data/spec/cucumber/ast/outline_table_spec.rb +1 -1
- data/spec/cucumber/ast/scenario_outline_spec.rb +15 -11
- data/spec/cucumber/ast/scenario_spec.rb +4 -4
- data/spec/cucumber/ast/step_spec.rb +3 -3
- data/spec/cucumber/ast/table_spec.rb +38 -2
- data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
- data/spec/cucumber/broadcaster_spec.rb +1 -1
- data/spec/cucumber/cli/configuration_spec.rb +32 -6
- data/spec/cucumber/cli/drb_client_spec.rb +2 -3
- data/spec/cucumber/cli/main_spec.rb +43 -43
- data/spec/cucumber/cli/options_spec.rb +28 -1
- data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
- data/spec/cucumber/core_ext/proc_spec.rb +1 -1
- data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
- data/spec/cucumber/formatter/duration_spec.rb +1 -1
- data/spec/cucumber/formatter/html_spec.rb +3 -5
- data/spec/cucumber/formatter/junit_spec.rb +16 -2
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +11 -12
- data/spec/cucumber/rb_support/rb_language_spec.rb +241 -28
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +33 -28
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
- data/spec/cucumber/step_match_spec.rb +11 -9
- data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
- data/spec/cucumber/wire_support/connection_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
- data/spec/cucumber/world/pending_spec.rb +2 -2
- data/spec/spec_helper.rb +13 -20
- metadata +11 -222
- data/.gitignore +0 -20
- data/Caliper.yml +0 -4
- data/History.txt +0 -1552
- data/README.rdoc +0 -26
- data/VERSION.yml +0 -5
- data/examples/i18n/ro/features/suma.feature +0 -11
- data/features/announce.feature +0 -164
- data/features/around_hooks.feature +0 -232
- data/features/bug_371.feature +0 -32
- data/features/bug_464.feature +0 -16
- data/features/bug_475.feature +0 -42
- data/features/bug_585_tab_indentation.feature +0 -22
- data/features/bug_600.feature +0 -67
- data/features/call_steps_from_stepdefs.feature +0 -154
- data/features/cucumber_cli.feature +0 -591
- data/features/cucumber_cli_outlines.feature +0 -117
- data/features/default_snippets.feature +0 -42
- data/features/diffing.feature +0 -25
- data/features/drb_server_integration.feature +0 -174
- data/features/exception_in_after_block.feature +0 -127
- data/features/exception_in_after_step_block.feature +0 -104
- data/features/exception_in_before_block.feature +0 -98
- data/features/exclude_files.feature +0 -20
- data/features/expand.feature +0 -60
- data/features/html_formatter.feature +0 -8
- data/features/html_formatter/a.html +0 -582
- data/features/junit_formatter.feature +0 -88
- data/features/language_from_header.feature +0 -30
- data/features/language_help.feature +0 -78
- data/features/listener_debugger_formatter.feature +0 -42
- data/features/multiline_names.feature +0 -44
- data/features/negative_tagged_hooks.feature +0 -60
- data/features/post_configuration_hook.feature +0 -37
- data/features/profiles.feature +0 -126
- data/features/rake_task.feature +0 -152
- data/features/report_called_undefined_steps.feature +0 -34
- data/features/rerun_formatter.feature +0 -45
- data/features/simplest.feature +0 -11
- data/features/snippet.feature +0 -23
- data/features/snippets_when_using_star_keyword.feature +0 -36
- data/features/step_definitions/extra_steps.rb +0 -2
- data/features/step_definitions/simplest_steps.rb +0 -3
- data/features/step_definitions/wire_steps.rb +0 -32
- data/features/support/env.rb.simplest +0 -7
- data/features/support/fake_wire_server.rb +0 -77
- data/features/table_diffing.feature +0 -45
- data/features/table_mapping.feature +0 -34
- data/features/tag_logic.feature +0 -258
- data/features/transform.feature +0 -245
- data/features/unicode_table.feature +0 -35
- data/features/usage_and_stepdefs_formatter.feature +0 -169
- data/features/wire_protocol.feature +0 -332
- data/features/wire_protocol_table_diffing.feature +0 -119
- data/features/wire_protocol_tags.feature +0 -87
- data/features/wire_protocol_timeouts.feature +0 -63
- data/features/work_in_progress.feature +0 -156
- data/fixtures/json/features/pystring.feature +0 -8
- data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +0 -12
- data/fixtures/self_test/features/background/background_with_name.feature +0 -7
- data/fixtures/self_test/features/background/failing_background.feature +0 -12
- data/fixtures/self_test/features/background/failing_background_after_success.feature +0 -11
- data/fixtures/self_test/features/background/multiline_args_background.feature +0 -32
- data/fixtures/self_test/features/background/passing_background.feature +0 -10
- data/fixtures/self_test/features/background/pending_background.feature +0 -10
- data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +0 -16
- data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +0 -16
- data/gem_tasks/features.rake +0 -14
- data/gem_tasks/sdoc.rake +0 -12
- data/lib/cucumber/ast/py_string.rb +0 -80
- data/lib/cucumber/formatter/color_io.rb +0 -23
- data/lib/cucumber/formatter/tag_cloud.rb +0 -35
- data/spec/cucumber/ast/py_string_spec.rb +0 -40
- data/spec/cucumber/formatter/color_io_spec.rb +0 -29
- data/spec/cucumber/step_mother_spec.rb +0 -302
|
@@ -20,20 +20,23 @@ module Cucumber
|
|
|
20
20
|
@scenario_number = 0
|
|
21
21
|
@step_number = 0
|
|
22
22
|
@header_red = nil
|
|
23
|
+
@delayed_messages = []
|
|
24
|
+
@img_id = 0
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
def embed(
|
|
27
|
+
def embed(src, mime_type, label)
|
|
26
28
|
case(mime_type)
|
|
27
29
|
when /^image\/(png|gif|jpg|jpeg)/
|
|
28
|
-
embed_image(
|
|
30
|
+
embed_image(src, label)
|
|
29
31
|
end
|
|
30
32
|
end
|
|
31
33
|
|
|
32
|
-
def embed_image(
|
|
33
|
-
id =
|
|
34
|
+
def embed_image(src, label)
|
|
35
|
+
id = "img_#{@img_id}"
|
|
36
|
+
@img_id += 1
|
|
34
37
|
@builder.span(:class => 'embed') do |pre|
|
|
35
|
-
pre << %{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false"
|
|
36
|
-
<img id="#{id}" style="display: none" src="#{
|
|
38
|
+
pre << %{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false">#{label}</a><br>
|
|
39
|
+
<img id="#{id}" style="display: none" src="#{src}"/>}
|
|
37
40
|
end
|
|
38
41
|
end
|
|
39
42
|
|
|
@@ -163,6 +166,9 @@ module Cucumber
|
|
|
163
166
|
end
|
|
164
167
|
|
|
165
168
|
def scenario_name(keyword, name, file_colon_line, source_indent)
|
|
169
|
+
@builder.span(:class => 'scenario_file') do
|
|
170
|
+
@builder << file_colon_line
|
|
171
|
+
end
|
|
166
172
|
@listing_background = false
|
|
167
173
|
@builder.h3(:id => "scenario_#{@scenario_number}") do
|
|
168
174
|
@builder.span(keyword + ':', :class => 'keyword')
|
|
@@ -245,6 +251,7 @@ module Cucumber
|
|
|
245
251
|
end
|
|
246
252
|
end
|
|
247
253
|
@builder << '</li>'
|
|
254
|
+
print_messages
|
|
248
255
|
end
|
|
249
256
|
|
|
250
257
|
def step_name(keyword, step_match, status, source_indent, background)
|
|
@@ -281,7 +288,7 @@ module Cucumber
|
|
|
281
288
|
end
|
|
282
289
|
end
|
|
283
290
|
|
|
284
|
-
def
|
|
291
|
+
def doc_string(string)
|
|
285
292
|
return if @hide_this_step
|
|
286
293
|
@builder.pre(:class => 'val') do |pre|
|
|
287
294
|
@builder << string.gsub("\n", '
')
|
|
@@ -298,6 +305,7 @@ module Cucumber
|
|
|
298
305
|
|
|
299
306
|
def after_table_row(table_row)
|
|
300
307
|
return if @hide_this_step
|
|
308
|
+
print_table_row_messages
|
|
301
309
|
@builder << '</tr>'
|
|
302
310
|
if table_row.exception
|
|
303
311
|
@builder.tr do
|
|
@@ -327,8 +335,35 @@ module Cucumber
|
|
|
327
335
|
@col_index += 1
|
|
328
336
|
end
|
|
329
337
|
|
|
330
|
-
def
|
|
331
|
-
@
|
|
338
|
+
def puts(message)
|
|
339
|
+
@delayed_messages << message
|
|
340
|
+
#@builder.pre(message, :class => 'message')
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def print_messages
|
|
344
|
+
return if @delayed_messages.empty?
|
|
345
|
+
|
|
346
|
+
#@builder.ol do
|
|
347
|
+
@delayed_messages.each do |ann|
|
|
348
|
+
@builder.li(:class => 'step message') do
|
|
349
|
+
@builder << ann
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
#end
|
|
353
|
+
empty_messages
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def print_table_row_messages
|
|
357
|
+
return if @delayed_messages.empty?
|
|
358
|
+
|
|
359
|
+
@builder.td(:class => 'message') do
|
|
360
|
+
@builder << @delayed_messages.join(", ")
|
|
361
|
+
end
|
|
362
|
+
empty_messages
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def empty_messages
|
|
366
|
+
@delayed_messages = []
|
|
332
367
|
end
|
|
333
368
|
|
|
334
369
|
protected
|
|
@@ -358,7 +393,7 @@ module Cucumber
|
|
|
358
393
|
end
|
|
359
394
|
|
|
360
395
|
def set_scenario_color(status)
|
|
361
|
-
if status == :undefined
|
|
396
|
+
if status == :undefined or status == :pending
|
|
362
397
|
set_scenario_color_pending
|
|
363
398
|
end
|
|
364
399
|
if status == :failed
|
|
@@ -523,7 +558,7 @@ module Cucumber
|
|
|
523
558
|
end
|
|
524
559
|
|
|
525
560
|
def backtrace_line(line)
|
|
526
|
-
line.gsub(
|
|
561
|
+
line.gsub(/\A([^:]*\.(?:rb|feature|haml)):(\d*).*\z/) do
|
|
527
562
|
if ENV['TM_PROJECT_DIRECTORY']
|
|
528
563
|
"<a href=\"txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}\">#{$1}:#{$2}</a> "
|
|
529
564
|
else
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
require 'cucumber/formatter/color_io'
|
|
2
|
-
|
|
3
1
|
module Cucumber
|
|
4
2
|
module Formatter
|
|
5
3
|
module Io
|
|
6
4
|
def ensure_io(path_or_io, name)
|
|
7
5
|
return nil if path_or_io.nil?
|
|
8
|
-
return path_or_io if
|
|
6
|
+
return path_or_io if path_or_io.respond_to?(:write)
|
|
9
7
|
file = File.open(path_or_io, Cucumber.file_mode('w'))
|
|
10
8
|
at_exit do
|
|
11
9
|
unless file.closed?
|
|
@@ -30,4 +28,4 @@ module Cucumber
|
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
end
|
|
33
|
-
end
|
|
31
|
+
end
|
|
@@ -1,166 +1,29 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require 'cucumber/formatter/gherkin_formatter_adapter'
|
|
2
|
+
require 'cucumber/formatter/io'
|
|
3
|
+
require 'gherkin/formatter/argument'
|
|
4
|
+
require 'gherkin/formatter/json_formatter'
|
|
3
5
|
|
|
4
6
|
module Cucumber
|
|
5
7
|
module Formatter
|
|
6
8
|
# The formatter used for <tt>--format json</tt>
|
|
7
|
-
class Json
|
|
8
|
-
class Error < StandardError
|
|
9
|
-
end
|
|
10
|
-
|
|
9
|
+
class Json < GherkinFormatterAdapter
|
|
11
10
|
include Io
|
|
12
11
|
|
|
13
12
|
def initialize(step_mother, io, options)
|
|
14
|
-
@io
|
|
15
|
-
@
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def before_features(features)
|
|
19
|
-
@json = {:features => []}
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def before_feature(feature)
|
|
23
|
-
@current_object = {:file => feature.file, :name => feature.name}
|
|
24
|
-
@json[:features] << @current_object
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def before_tags(tags)
|
|
28
|
-
@current_object[:tags] = tags.tag_names.to_a
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def before_background(background)
|
|
32
|
-
background = {}
|
|
33
|
-
@current_object[:background] = background
|
|
34
|
-
@current_object = background
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def after_background(background)
|
|
38
|
-
@current_object = last_feature
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def before_feature_element(feature_element)
|
|
42
|
-
elements = @current_object[:elements] ||= []
|
|
43
|
-
|
|
44
|
-
# change current object to the feature_element
|
|
45
|
-
@current_object = {}
|
|
46
|
-
elements << @current_object
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def scenario_name(keyword, name, file_colon_line, source_indent)
|
|
50
|
-
@current_object[:keyword] = keyword
|
|
51
|
-
@current_object[:name] = name
|
|
52
|
-
@current_object[:file_colon_line] = file_colon_line
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def before_steps(steps)
|
|
56
|
-
@current_object[:steps] = []
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def before_step(step)
|
|
60
|
-
@current_step = {}
|
|
61
|
-
@current_object[:steps] << @current_step
|
|
13
|
+
@io = ensure_io(io, "json")
|
|
14
|
+
@obj = {'features' => []}
|
|
15
|
+
super(Gherkin::Formatter::JSONFormatter.new(nil), false)
|
|
62
16
|
end
|
|
63
17
|
|
|
64
|
-
def
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def step_name(keyword, step_match, status, source_indent, background)
|
|
71
|
-
@current_step[:status] = status
|
|
72
|
-
@current_step[:keyword] = keyword
|
|
73
|
-
@current_step[:name] = "#{step_match.name || step_match.format_args}"
|
|
74
|
-
@current_step[:file_colon_line] = step_match.file_colon_line
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def after_step(step)
|
|
78
|
-
@current_step = nil
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def before_examples(examples)
|
|
82
|
-
@current_object[:examples] = {}
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def examples_name(keyword, name)
|
|
86
|
-
@current_object[:examples][:name] = "#{keyword} #{name}"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def before_outline_table(*args)
|
|
90
|
-
@current_object[:examples][:table] = []
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def before_table_row(row)
|
|
94
|
-
@current_row = {:cells => []}
|
|
95
|
-
|
|
96
|
-
if @current_object.member? :examples
|
|
97
|
-
@current_object[:examples][:table] << @current_row
|
|
98
|
-
elsif @current_step
|
|
99
|
-
(@current_step[:table] ||= []) << @current_row
|
|
100
|
-
else
|
|
101
|
-
internal_error
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def table_cell_value(value, status)
|
|
106
|
-
@current_row[:cells] << {:text => value, :status => status}
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def after_table_row(row)
|
|
110
|
-
if row.exception
|
|
111
|
-
@current_row[:exception] = exception_hash_for(row.exception)
|
|
112
|
-
end
|
|
113
|
-
@current_row = nil
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def py_string(string)
|
|
117
|
-
@current_step[:py_string] = string
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def after_feature_element(feature_element)
|
|
121
|
-
# change current object back to the last feature
|
|
122
|
-
@current_object = last_feature
|
|
18
|
+
def after_feature(feature)
|
|
19
|
+
super
|
|
20
|
+
@obj['features'] << @gf.gherkin_object
|
|
123
21
|
end
|
|
124
22
|
|
|
125
23
|
def after_features(features)
|
|
126
|
-
@io.write
|
|
127
|
-
@io.flush
|
|
24
|
+
@io.write(@obj.to_json)
|
|
128
25
|
end
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
obj[:embedded] ||= []
|
|
133
|
-
|
|
134
|
-
obj[:embedded] << {
|
|
135
|
-
:file => file,
|
|
136
|
-
:mime_type => mime_type,
|
|
137
|
-
:data => [File.read(file)].pack("m*") # base64
|
|
138
|
-
}
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
private
|
|
142
|
-
|
|
143
|
-
def json_string
|
|
144
|
-
@json.to_json
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def last_feature
|
|
148
|
-
@json[:features].last
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def exception_hash_for(e)
|
|
152
|
-
{
|
|
153
|
-
:class => e.class.name,
|
|
154
|
-
:message => e.message,
|
|
155
|
-
:backtrace => e.backtrace
|
|
156
|
-
}
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def internal_error
|
|
160
|
-
raise Error, "you've found a bug in the JSON formatter!"
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
end # Json
|
|
164
|
-
end # Formatter
|
|
165
|
-
end # Cucumber
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
166
29
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'cucumber/formatter/json'
|
|
2
2
|
|
|
3
3
|
module Cucumber
|
|
4
4
|
module Formatter
|
|
5
5
|
# The formatter used for <tt>--format json_pretty</tt>
|
|
6
6
|
class JsonPretty < Json
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
JSON.pretty_generate @json
|
|
7
|
+
def after_features(features)
|
|
8
|
+
@io.write(JSON.pretty_generate(@obj))
|
|
10
9
|
end
|
|
11
|
-
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
|
-
end
|
|
12
|
+
end
|
|
13
|
+
|
|
@@ -21,17 +21,22 @@ module Cucumber
|
|
|
21
21
|
|
|
22
22
|
def before_feature(feature)
|
|
23
23
|
@current_feature = feature
|
|
24
|
-
@failures = @errors = @tests = 0
|
|
24
|
+
@failures = @errors = @tests = @skipped = 0
|
|
25
25
|
@builder = OrderedXmlMarkup.new( :indent => 2 )
|
|
26
26
|
@time = 0
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
def before_feature_element(feature_element)
|
|
30
|
+
@in_examples = Ast::ScenarioOutline === feature_element
|
|
31
|
+
end
|
|
32
|
+
|
|
29
33
|
def after_feature(feature)
|
|
30
34
|
@testsuite = OrderedXmlMarkup.new( :indent => 2 )
|
|
31
35
|
@testsuite.instruct!
|
|
32
36
|
@testsuite.testsuite(
|
|
33
37
|
:failures => @failures,
|
|
34
38
|
:errors => @errors,
|
|
39
|
+
:skipped => @skipped,
|
|
35
40
|
:tests => @tests,
|
|
36
41
|
:time => "%.6f" % @time,
|
|
37
42
|
:name => @feature_name ) do
|
|
@@ -56,13 +61,8 @@ module Cucumber
|
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
def scenario_name(keyword, name, file_colon_line, source_indent)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
scenario_name = "Unnamed scenario" if name == ""
|
|
62
|
-
@scenario = scenario_name
|
|
63
|
-
description = "Scenario"
|
|
64
|
-
description << " outline" if keyword.include?('Scenario Outline')
|
|
65
|
-
@output = "#{description}: #{@scenario}\n\n"
|
|
64
|
+
@scenario = (name.nil? || name == "") ? "Unnamed scenario" : name.split("\n")[0]
|
|
65
|
+
@output = "#{keyword}: #{@scenario}\n\n"
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def before_steps(steps)
|
|
@@ -96,7 +96,7 @@ module Cucumber
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def after_table_row(table_row)
|
|
99
|
-
return unless @in_examples
|
|
99
|
+
return unless @in_examples and Cucumber::Ast::OutlineTable::ExampleRow === table_row
|
|
100
100
|
duration = Time.now - @table_start
|
|
101
101
|
unless @header_row
|
|
102
102
|
name_suffix = " (outline example : #{table_row.name})"
|
|
@@ -116,20 +116,23 @@ module Cucumber
|
|
|
116
116
|
@time += duration
|
|
117
117
|
classname = "#{@feature_name}.#{@scenario}"
|
|
118
118
|
name = "#{@scenario}#{suffix}"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
end
|
|
128
|
-
@failures += 1
|
|
119
|
+
pending = [:pending, :undefined].include?(status)
|
|
120
|
+
passed = (status == :passed || (pending && !@options[:strict]))
|
|
121
|
+
|
|
122
|
+
@builder.testcase(:classname => classname, :name => name, :time => "%.6f" % duration) do
|
|
123
|
+
unless passed
|
|
124
|
+
@builder.failure(:message => "#{status.to_s} #{name}", :type => status.to_s) do
|
|
125
|
+
@builder.cdata! @output
|
|
126
|
+
@builder.cdata!(format_exception(exception)) if exception
|
|
129
127
|
end
|
|
128
|
+
@failures += 1
|
|
129
|
+
end
|
|
130
|
+
if passed and (status == :skipped || pending)
|
|
131
|
+
@builder.skipped
|
|
132
|
+
@skipped += 1
|
|
130
133
|
end
|
|
131
|
-
@tests += 1
|
|
132
134
|
end
|
|
135
|
+
@tests += 1
|
|
133
136
|
end
|
|
134
137
|
|
|
135
138
|
def format_exception(exception)
|
|
@@ -137,9 +140,12 @@ module Cucumber
|
|
|
137
140
|
end
|
|
138
141
|
|
|
139
142
|
def feature_result_filename(feature_file)
|
|
143
|
+
File.join(@reportdir, "TEST-#{basename(feature_file)}.xml")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def basename(feature_file)
|
|
140
147
|
ext_length = File.extname(feature_file).length
|
|
141
|
-
|
|
142
|
-
File.join(@reportdir, "TEST-#{basename}.xml")
|
|
148
|
+
feature_file.gsub('features/', '').gsub(File::SEPARATOR, '_')[0...-ext_length]
|
|
143
149
|
end
|
|
144
150
|
|
|
145
151
|
def write_file(feature_filename, data)
|
|
@@ -28,9 +28,9 @@ module Cucumber
|
|
|
28
28
|
@file = ensure_file(path_or_io, "pdf")
|
|
29
29
|
|
|
30
30
|
if(options[:dry_run])
|
|
31
|
-
@status_colors = { :passed => BLACK, :skipped => BLACK, :undefined => BLACK, :failed => BLACK, :
|
|
31
|
+
@status_colors = { :passed => BLACK, :skipped => BLACK, :undefined => BLACK, :failed => BLACK, :putsd => GREY}
|
|
32
32
|
else
|
|
33
|
-
@status_colors = { :passed => '055902', :skipped => GREY, :undefined => 'F27405', :failed => '730202', :
|
|
33
|
+
@status_colors = { :passed => '055902', :skipped => GREY, :undefined => 'F27405', :failed => '730202', :putsd => GREY}
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
@pdf = Prawn::Document.new
|
|
@@ -71,9 +71,9 @@ module Cucumber
|
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
def
|
|
75
|
-
@pdf.fill_color(@status_colors[:
|
|
76
|
-
@pdf.text
|
|
74
|
+
def puts(message)
|
|
75
|
+
@pdf.fill_color(@status_colors[:putsd])
|
|
76
|
+
@pdf.text message, :size => 10
|
|
77
77
|
@pdf.fill_color BLACK
|
|
78
78
|
end
|
|
79
79
|
|
|
@@ -172,7 +172,7 @@ module Cucumber
|
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
174
|
|
|
175
|
-
def
|
|
175
|
+
def before_doc_string(string)
|
|
176
176
|
return if @hide_this_step
|
|
177
177
|
s = %{"""\n#{string}\n"""}.indent(10)
|
|
178
178
|
s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}
|