cucumber 3.0.0.pre.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +32 -0
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- data/.rubocop_todo.yml +1 -85
- data/.travis.yml +2 -2
- data/{History.md → CHANGELOG.md} +69 -13
- data/appveyor.yml +2 -1
- data/bin/cucumber +2 -1
- data/cucumber.gemspec +1 -1
- data/examples/i18n/ar/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/bg/features/support/env.rb +6 -1
- data/examples/i18n/bg/lib/calculator.rb +2 -1
- data/examples/i18n/ca/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/cs/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/da/features/step_definitions/lommeregner_steps.rb +6 -1
- data/examples/i18n/de/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/el/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/en-lol/features/support/env.rb +6 -2
- data/examples/i18n/en/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/eo/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/es/features/step_definitions/calculador_steps.rb +6 -1
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +6 -1
- data/examples/i18n/fi/features/step_definitions/laskin_steps.rb +6 -1
- data/examples/i18n/fr/features/support/env.rb +6 -1
- data/examples/i18n/he/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/hi/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb +6 -2
- data/examples/i18n/hu/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/id/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb +6 -1
- data/examples/i18n/ja/features/support/env.rb +6 -1
- data/examples/i18n/ko/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/lt/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/lv/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/no/features/support/env.rb +6 -1
- data/examples/i18n/pl/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/pl/features/support/env.rb +6 -1
- data/examples/i18n/pt/features/support/env.rb +6 -1
- data/examples/i18n/ro/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/ru/features/support/env.rb +6 -1
- data/examples/i18n/ru/lib/calculator.rb +2 -1
- data/examples/i18n/sk/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/sr-Cyrl/features/support/env.rb +6 -1
- data/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb +6 -1
- data/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb +6 -1
- data/examples/i18n/uk/features/support/env.rb +6 -1
- data/examples/i18n/uk/lib/calculator.rb +2 -1
- data/examples/i18n/uz/features/support/env.rb +6 -1
- data/examples/i18n/uz/lib/calculator.rb +2 -1
- data/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb +6 -1
- data/examples/sinatra/features/support/env.rb +6 -1
- data/examples/tcl/features/support/env.rb +2 -1
- data/examples/watir/features/step_definitions/search_steps.rb +4 -3
- data/examples/watir/features/support/env.rb +5 -1
- data/features/docs/api/listen_for_events.feature +2 -2
- data/features/docs/cli/execute_with_tag_filter.feature +4 -2
- data/features/docs/defining_steps/ambiguous_steps.feature +89 -0
- data/features/docs/events/{test_case_starting_event.feature → test_case_started_event.feature} +3 -3
- data/features/docs/events/{test_run_starting_event.feature → test_run_started_event.feature} +5 -5
- data/features/docs/events/test_step_finished_event.feature +1 -1
- data/features/docs/events/{test_step_starting_event.feature → test_step_started_event.feature} +3 -3
- data/features/docs/extending_cucumber/custom_formatter.feature +5 -33
- data/features/docs/gherkin/outlines.feature +2 -4
- data/features/docs/writing_support_code/parameter_types.feature +1 -23
- data/features/lib/step_definitions/iso-8859-1_steps.rb +6 -3
- data/features/lib/support/fake_wire_server.rb +9 -1
- data/features/lib/support/parameter_types.rb +1 -4
- data/gem_tasks/fix_cr_lf.rake +17 -6
- data/lib/autotest/cucumber_mixin.rb +1 -1
- data/lib/cucumber/cli/configuration.rb +2 -2
- data/lib/cucumber/cli/options.rb +62 -41
- data/lib/cucumber/cli/profile_loader.rb +1 -1
- data/lib/cucumber/configuration.rb +3 -2
- data/lib/cucumber/deprecate.rb +2 -2
- data/lib/cucumber/events.rb +3 -3
- data/lib/cucumber/events/test_case_finished.rb +1 -1
- data/lib/cucumber/events/{test_case_starting.rb → test_case_started.rb} +1 -1
- data/lib/cucumber/events/{test_run_starting.rb → test_run_started.rb} +1 -1
- data/lib/cucumber/events/{test_step_starting.rb → test_step_started.rb} +1 -1
- data/lib/cucumber/filters.rb +1 -1
- data/lib/cucumber/filters/activate_steps.rb +6 -2
- data/lib/cucumber/filters/{broadcast_test_run_starting_event.rb → broadcast_test_run_started_event.rb} +2 -2
- data/lib/cucumber/formatter/console.rb +1 -1
- data/lib/cucumber/formatter/console_issues.rb +2 -2
- data/lib/cucumber/formatter/fail_fast.rb +1 -1
- data/lib/cucumber/formatter/html.rb +9 -10
- data/lib/cucumber/formatter/html_builder.rb +21 -11
- data/lib/cucumber/formatter/io.rb +1 -1
- data/lib/cucumber/formatter/json.rb +13 -12
- data/lib/cucumber/formatter/junit.rb +7 -7
- data/lib/cucumber/formatter/legacy_api/adapter.rb +30 -14
- data/lib/cucumber/formatter/legacy_api/ast.rb +10 -2
- data/lib/cucumber/formatter/progress.rb +2 -2
- data/lib/cucumber/formatter/rerun.rb +1 -1
- data/lib/cucumber/formatter/summary.rb +1 -1
- data/lib/cucumber/glue/dsl.rb +7 -25
- data/lib/cucumber/glue/proto_world.rb +0 -5
- data/lib/cucumber/hooks.rb +4 -4
- data/lib/cucumber/multiline_argument.rb +3 -11
- data/lib/cucumber/multiline_argument/data_table.rb +5 -3
- data/lib/cucumber/project_initializer.rb +1 -1
- data/lib/cucumber/rake/task.rb +8 -4
- data/lib/cucumber/runtime.rb +2 -2
- data/lib/cucumber/runtime/support_code.rb +1 -1
- data/lib/cucumber/runtime/user_interface.rb +5 -5
- data/lib/cucumber/step_match.rb +13 -0
- data/lib/cucumber/version +1 -1
- data/scripts/{update-history → update-changelog} +14 -11
- data/spec/cucumber/cli/configuration_spec.rb +13 -1
- data/spec/cucumber/cli/options_spec.rb +1 -1
- data/spec/cucumber/filters/activate_steps_spec.rb +4 -4
- data/spec/cucumber/formatter/fail_fast_spec.rb +1 -1
- data/spec/cucumber/formatter/html_spec.rb +1 -1
- data/spec/cucumber/formatter/json_spec.rb +26 -51
- data/spec/cucumber/formatter/junit_spec.rb +4 -4
- data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +86 -98
- data/spec/cucumber/formatter/pretty_spec.rb +0 -13
- data/spec/cucumber/glue/snippet_spec.rb +2 -2
- data/spec/cucumber/hooks_spec.rb +2 -2
- data/spec/cucumber/multiline_argument/data_table_spec.rb +10 -5
- data/spec/cucumber/rake/forked_spec.rb +15 -11
- data/spec/cucumber/world/pending_spec.rb +1 -1
- data/spec/support/standard_step_actions.rb +1 -1
- metadata +25 -25
- data/features/docs/formatters/formatter_step_file_colon_line.feature +0 -44
@@ -5,20 +5,18 @@ require 'pathname'
|
|
5
5
|
module Cucumber
|
6
6
|
module Formatter
|
7
7
|
class HtmlBuilder < Builder::XmlMarkup
|
8
|
-
|
9
|
-
raise ArgumentError, 'missing required argument' unless src && label && id # for Ruby 2.0 compatibility
|
8
|
+
VALID_EMBED_TYPES = [:text, :image].freeze
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
class InvalidEmbedTypeError < ::StandardError
|
11
|
+
MESSAGE = 'Invalid embed type. Valid types are :text and :image.'.freeze
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
def initialize(message=MESSAGE)
|
14
|
+
super(message)
|
15
|
+
end
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
%{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false">#{label}</a><br>
|
20
|
-
<img id="#{id}" style="display: none" src="#{src}"/>}
|
21
|
-
)
|
18
|
+
def embed(type: nil, src: nil, label: nil, id: nil)
|
19
|
+
prepend_to_span('embed', string_to_embed(type: type, src: src, label: label, id: id))
|
22
20
|
end
|
23
21
|
|
24
22
|
def declare!
|
@@ -51,6 +49,18 @@ module Cucumber
|
|
51
49
|
|
52
50
|
private
|
53
51
|
|
52
|
+
def string_to_embed(type: nil, src: nil, label: nil, id: nil)
|
53
|
+
raise ::ArgumentError, 'missing required argument' unless type && src && label && id # for Ruby 2.0 compatibility
|
54
|
+
raise InvalidEmbedTypeError unless VALID_EMBED_TYPES.include?(type)
|
55
|
+
|
56
|
+
if type == :image
|
57
|
+
%{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false">#{label}</a><br>
|
58
|
+
<img id="#{id}" style="display: none" src="#{src}"/>}
|
59
|
+
else
|
60
|
+
%{<a id="#{id}" href="#{src}" title="#{label}">#{label}</a>}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
54
64
|
def summary_div
|
55
65
|
div(id: 'summary') do
|
56
66
|
p('', id: 'totals')
|
@@ -28,7 +28,7 @@ module Cucumber
|
|
28
28
|
raise "You *must* specify --out DIR for the #{name} formatter" unless String === path
|
29
29
|
raise "I can't write #{name} reports to a file - it has to be a directory" if File.file?(path)
|
30
30
|
FileUtils.mkdir_p(path) unless File.directory?(path)
|
31
|
-
path
|
31
|
+
File.absolute_path path
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -14,14 +14,15 @@ module Cucumber
|
|
14
14
|
def initialize(config)
|
15
15
|
@io = ensure_io(config.out_stream)
|
16
16
|
@feature_hashes = []
|
17
|
-
|
17
|
+
@step_or_hook_hash = {}
|
18
|
+
config.on_event :test_case_started, &method(:on_test_case_started)
|
18
19
|
config.on_event :test_case_finished, &method(:on_test_case_finished)
|
19
|
-
config.on_event :
|
20
|
+
config.on_event :test_step_started, &method(:on_test_step_started)
|
20
21
|
config.on_event :test_step_finished, &method(:on_test_step_finished)
|
21
22
|
config.on_event :test_run_finished, &method(:on_test_run_finished)
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
+
def on_test_case_started(event)
|
25
26
|
test_case = event.test_case
|
26
27
|
builder = Builder.new(test_case)
|
27
28
|
unless same_feature_as_previous_test_case?(test_case.feature)
|
@@ -39,7 +40,7 @@ module Cucumber
|
|
39
40
|
@any_step_failed = false
|
40
41
|
end
|
41
42
|
|
42
|
-
def
|
43
|
+
def on_test_step_started(event)
|
43
44
|
test_step = event.test_step
|
44
45
|
return if internal_hook?(test_step)
|
45
46
|
hook_query = HookQueryVisitor.new(test_step)
|
@@ -101,7 +102,7 @@ module Cucumber
|
|
101
102
|
end
|
102
103
|
|
103
104
|
def first_step_after_background?(test_step)
|
104
|
-
test_step.source[1].
|
105
|
+
test_step.source[1].to_s != @element_hash[:name]
|
105
106
|
end
|
106
107
|
|
107
108
|
def internal_hook?(test_step)
|
@@ -129,7 +130,7 @@ module Cucumber
|
|
129
130
|
when :after_step
|
130
131
|
return after_step_hooks
|
131
132
|
else
|
132
|
-
fail '
|
133
|
+
fail 'Unknown hook type ' + hook_query.type.to_s
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
@@ -160,7 +161,7 @@ module Cucumber
|
|
160
161
|
def create_step_hash(step_source)
|
161
162
|
step_hash = {
|
162
163
|
keyword: step_source.keyword,
|
163
|
-
name: step_source.
|
164
|
+
name: step_source.to_s,
|
164
165
|
line: step_source.location.line
|
165
166
|
}
|
166
167
|
step_hash[:comments] = Formatter.create_comments_array(step_source.comments) unless step_source.comments.empty?
|
@@ -239,7 +240,7 @@ module Cucumber
|
|
239
240
|
uri: feature.file,
|
240
241
|
id: create_id(feature),
|
241
242
|
keyword: feature.keyword,
|
242
|
-
name: feature.
|
243
|
+
name: feature.to_s,
|
243
244
|
description: feature.description,
|
244
245
|
line: feature.location.line
|
245
246
|
}
|
@@ -258,7 +259,7 @@ module Cucumber
|
|
258
259
|
def background(background)
|
259
260
|
@background_hash = {
|
260
261
|
keyword: background.keyword,
|
261
|
-
name: background.
|
262
|
+
name: background.to_s,
|
262
263
|
description: background.description,
|
263
264
|
line: background.location.line,
|
264
265
|
type: 'background'
|
@@ -270,7 +271,7 @@ module Cucumber
|
|
270
271
|
@test_case_hash = {
|
271
272
|
id: create_id(scenario),
|
272
273
|
keyword: scenario.keyword,
|
273
|
-
name: scenario.
|
274
|
+
name: scenario.to_s,
|
274
275
|
description: scenario.description,
|
275
276
|
line: scenario.location.line,
|
276
277
|
type: 'scenario'
|
@@ -283,7 +284,7 @@ module Cucumber
|
|
283
284
|
@test_case_hash = {
|
284
285
|
id: create_id(scenario) + ';' + @example_id,
|
285
286
|
keyword: scenario.keyword,
|
286
|
-
name: scenario.
|
287
|
+
name: scenario.to_s,
|
287
288
|
description: scenario.description,
|
288
289
|
line: @row.location.line,
|
289
290
|
type: 'scenario'
|
@@ -316,7 +317,7 @@ module Cucumber
|
|
316
317
|
private
|
317
318
|
|
318
319
|
def create_id(element)
|
319
|
-
element.
|
320
|
+
element.to_s.downcase.tr(' ', '-')
|
320
321
|
end
|
321
322
|
|
322
323
|
def create_tags_array(tags)
|
@@ -19,7 +19,7 @@ module Cucumber
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize(config)
|
22
|
-
config.on_event :
|
22
|
+
config.on_event :test_case_started, &method(:on_test_case_started)
|
23
23
|
config.on_event :test_case_finished, &method(:on_test_case_finished)
|
24
24
|
config.on_event :test_step_finished, &method(:on_test_step_finished)
|
25
25
|
config.on_event :test_run_finished, &method(:on_test_run_finished)
|
@@ -36,7 +36,7 @@ module Cucumber
|
|
36
36
|
}}
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
39
|
+
def on_test_case_started(event)
|
40
40
|
test_case = event.test_case
|
41
41
|
unless same_feature_as_previous_test_case?(test_case.feature)
|
42
42
|
start_feature(test_case.feature)
|
@@ -52,7 +52,7 @@ module Cucumber
|
|
52
52
|
test_step, result = *event.attributes
|
53
53
|
return if @failing_step_source
|
54
54
|
|
55
|
-
@failing_step_source = test_step.source.last unless result.ok?(@config.strict
|
55
|
+
@failing_step_source = test_step.source.last unless result.ok?(@config.strict)
|
56
56
|
end
|
57
57
|
|
58
58
|
def on_test_case_finished(event)
|
@@ -102,10 +102,10 @@ module Cucumber
|
|
102
102
|
|
103
103
|
def create_output_string(test_case, scenario, result, row_name)
|
104
104
|
output = "#{test_case.keyword}: #{scenario}\n\n"
|
105
|
-
return output if result.ok?(@config.strict
|
105
|
+
return output if result.ok?(@config.strict)
|
106
106
|
if test_case.keyword == 'Scenario'
|
107
107
|
output += @failing_step_source.keyword.to_s unless hook?(@failing_step_source)
|
108
|
-
output += "#{@failing_step_source
|
108
|
+
output += "#{@failing_step_source}\n"
|
109
109
|
else
|
110
110
|
output += "Example row: #{row_name}\n"
|
111
111
|
end
|
@@ -113,7 +113,7 @@ module Cucumber
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def hook?(step)
|
116
|
-
['Before hook', 'After hook', 'AfterStep hook'].include? step.
|
116
|
+
['Before hook', 'After hook', 'AfterStep hook'].include? step.text
|
117
117
|
end
|
118
118
|
|
119
119
|
def build_testcase(result, scenario_designation, output)
|
@@ -123,7 +123,7 @@ module Cucumber
|
|
123
123
|
name = scenario_designation
|
124
124
|
|
125
125
|
@current_feature_data[:builder].testcase(:classname => classname, :name => name, :time => format('%.6f', duration)) do
|
126
|
-
if !result.passed? && result.ok?(@config.strict
|
126
|
+
if !result.passed? && result.ok?(@config.strict)
|
127
127
|
@current_feature_data[:builder].skipped
|
128
128
|
@current_feature_data[:skipped] += 1
|
129
129
|
elsif !result.passed?
|
@@ -15,12 +15,14 @@ module Cucumber
|
|
15
15
|
|
16
16
|
def initialize(*)
|
17
17
|
super
|
18
|
+
emit_deprecation_warning
|
19
|
+
|
18
20
|
@matches = collect_matches
|
19
|
-
config.on_event(:
|
21
|
+
config.on_event(:test_case_started) do |event|
|
20
22
|
formatter.before_test_case(event.test_case)
|
21
23
|
printer.before_test_case(event.test_case)
|
22
24
|
end
|
23
|
-
config.on_event(:
|
25
|
+
config.on_event(:test_step_started) do |event|
|
24
26
|
formatter.before_test_step(event.test_step)
|
25
27
|
printer.before_test_step(event.test_step)
|
26
28
|
end
|
@@ -50,6 +52,20 @@ module Cucumber
|
|
50
52
|
|
51
53
|
private
|
52
54
|
|
55
|
+
def emit_deprecation_warning
|
56
|
+
parent_name = formatter_class_name =~ /::[^:]+\Z/ ? $`.freeze : nil
|
57
|
+
return if parent_name == 'Cucumber::Formatter'
|
58
|
+
return if !config.out_stream # some unit tests don't set it
|
59
|
+
config.out_stream.puts "WARNING: The formatter #{formatter.class.name} is using the deprecated formatter API which will be removed in v4.0 of Cucumber."
|
60
|
+
config.out_stream.puts
|
61
|
+
end
|
62
|
+
|
63
|
+
def formatter_class_name
|
64
|
+
formatter.class.name
|
65
|
+
rescue NoMethodError # when we use the Fanout, things get gnarly
|
66
|
+
formatter.class[0].class.name
|
67
|
+
end
|
68
|
+
|
53
69
|
def printer
|
54
70
|
@printer ||= FeaturesPrinter.new(formatter, results, config, @matches).before
|
55
71
|
end
|
@@ -185,7 +201,7 @@ module Cucumber
|
|
185
201
|
class StepSource < OpenStruct
|
186
202
|
def build_step_invocation(indent, matches, config, messages, embeddings)
|
187
203
|
step_result.step_invocation(
|
188
|
-
matches.fetch(step) { NoStepMatch.new(step, step.
|
204
|
+
matches.fetch(step) { NoStepMatch.new(step, step.text) },
|
189
205
|
step,
|
190
206
|
indent,
|
191
207
|
background,
|
@@ -330,7 +346,7 @@ module Cucumber
|
|
330
346
|
elsif source.scenario
|
331
347
|
ScenarioPrinter.new(formatter, source.scenario, before_hook_results)
|
332
348
|
elsif source.scenario_outline
|
333
|
-
if same_scenario_outline_as_previous_test_case?(source)
|
349
|
+
if same_scenario_outline_as_previous_test_case?(source) && @previous_outline_child
|
334
350
|
@previous_outline_child
|
335
351
|
else
|
336
352
|
ScenarioOutlinePrinter.new(formatter, config, source.scenario_outline)
|
@@ -388,19 +404,19 @@ module Cucumber
|
|
388
404
|
@previous_outline_child.after unless same_scenario_outline_as_previous_test_case?(source)
|
389
405
|
end
|
390
406
|
end
|
391
|
-
if
|
407
|
+
if from_scenario_outline_to_hidden_background(@child, child)
|
392
408
|
@previous_outline_child = @child
|
393
409
|
else
|
394
410
|
@child.after
|
395
411
|
@previous_outline_child = nil
|
396
412
|
end
|
397
413
|
end
|
398
|
-
child.before unless to_scenario_outline(child)
|
414
|
+
child.before unless to_scenario_outline(child) && same_scenario_outline_as_previous_test_case?(source)
|
399
415
|
@child = child
|
400
416
|
end
|
401
417
|
|
402
|
-
def
|
403
|
-
from.class.name == ScenarioOutlinePrinter.name
|
418
|
+
def from_scenario_outline_to_hidden_background(from, to)
|
419
|
+
from.class.name == ScenarioOutlinePrinter.name &&
|
404
420
|
to.class.name == HiddenBackgroundPrinter.name
|
405
421
|
end
|
406
422
|
|
@@ -612,7 +628,7 @@ module Cucumber
|
|
612
628
|
|
613
629
|
def after
|
614
630
|
@child.after if @child
|
615
|
-
# TODO
|
631
|
+
# TODO: the last step result might not accurately reflect the
|
616
632
|
# overall scenario result.
|
617
633
|
scenario_outline = last_step_result.scenario_outline(node.name, node.location)
|
618
634
|
formatter.after_feature_element(scenario_outline)
|
@@ -641,7 +657,7 @@ module Cucumber
|
|
641
657
|
end
|
642
658
|
|
643
659
|
def outline_step(step)
|
644
|
-
step_match = NoStepMatch.new(step, step.
|
660
|
+
step_match = NoStepMatch.new(step, step.text)
|
645
661
|
step_invocation = LegacyResultBuilder.new(Core::Test::Result::Skipped.new).
|
646
662
|
step_invocation(step_match, step, indent, nil, configuration, [], [])
|
647
663
|
steps_printer.step_invocation step_invocation
|
@@ -914,11 +930,11 @@ module Cucumber
|
|
914
930
|
def of(node)
|
915
931
|
# The length of the instantiated steps in --expand mode are currently
|
916
932
|
# not included in the calculation of max => make sure to return >= 1
|
917
|
-
[1, max - node.
|
933
|
+
[1, max - node.to_s.length - node.keyword.length].max
|
918
934
|
end
|
919
935
|
|
920
936
|
def record_width_of(node)
|
921
|
-
@widths << node.keyword.length + node.
|
937
|
+
@widths << node.keyword.length + node.to_s.length + 1
|
922
938
|
end
|
923
939
|
|
924
940
|
private
|
@@ -989,8 +1005,8 @@ module Cucumber
|
|
989
1005
|
|
990
1006
|
def step_exception(step, configuration)
|
991
1007
|
return filtered_step_exception(step) if @exception
|
992
|
-
return nil unless @status == :undefined && configuration.strict?
|
993
|
-
@exception = Cucumber::Undefined.from(@result, step.
|
1008
|
+
return nil unless @status == :undefined && configuration.strict.strict?(:undefined)
|
1009
|
+
@exception = Cucumber::Undefined.from(@result, step.text)
|
994
1010
|
@exception.backtrace << step.backtrace_line
|
995
1011
|
filtered_step_exception(step)
|
996
1012
|
end
|
@@ -103,7 +103,7 @@ module Cucumber
|
|
103
103
|
:embeddings) do
|
104
104
|
extend Forwardable
|
105
105
|
|
106
|
-
def_delegators :step, :keyword, :
|
106
|
+
def_delegators :step, :keyword, :text, :multiline_arg, :location
|
107
107
|
|
108
108
|
def accept(formatter)
|
109
109
|
formatter.before_step(self)
|
@@ -119,7 +119,7 @@ module Cucumber
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def step_result_attributes
|
122
|
-
legacy_multiline_arg = if multiline_arg.
|
122
|
+
legacy_multiline_arg = if multiline_arg.is_a?(Core::Ast::EmptyMultilineArgument)
|
123
123
|
nil
|
124
124
|
else
|
125
125
|
step.multiline_arg
|
@@ -155,6 +155,10 @@ module Cucumber
|
|
155
155
|
self
|
156
156
|
end
|
157
157
|
|
158
|
+
def to_s
|
159
|
+
text
|
160
|
+
end
|
161
|
+
|
158
162
|
private
|
159
163
|
|
160
164
|
def source_indent
|
@@ -240,6 +244,10 @@ module Cucumber
|
|
240
244
|
'| ' + cells.join(' | ') + ' |'
|
241
245
|
end
|
242
246
|
|
247
|
+
def to_s
|
248
|
+
name
|
249
|
+
end
|
250
|
+
|
243
251
|
def failed?
|
244
252
|
status == :failed
|
245
253
|
end
|
@@ -31,7 +31,7 @@ module Cucumber
|
|
31
31
|
@counts = ConsoleCounts.new(config)
|
32
32
|
@issues = ConsoleIssues.new(config)
|
33
33
|
config.on_event :step_activated, &method(:on_step_activated)
|
34
|
-
config.on_event :
|
34
|
+
config.on_event :test_case_started, &method(:on_test_case_started)
|
35
35
|
config.on_event :test_step_finished, &method(:on_test_step_finished)
|
36
36
|
config.on_event :test_case_finished, &method(:on_test_case_finished)
|
37
37
|
config.on_event :test_run_finished, &method(:on_test_run_finished)
|
@@ -41,7 +41,7 @@ module Cucumber
|
|
41
41
|
@matches[event.test_step.source] = event.step_match
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def on_test_case_started(_event)
|
45
45
|
unless @profile_information_printed
|
46
46
|
do_print_profile_information(config.profiles) unless config.skip_profile_information? || config.profiles.nil? || config.profiles.empty?
|
47
47
|
@profile_information_printed = true
|
@@ -12,7 +12,7 @@ module Cucumber
|
|
12
12
|
@failures = {}
|
13
13
|
config.on_event :test_case_finished do |event|
|
14
14
|
test_case, result = *event.attributes
|
15
|
-
next if result.ok?(@config.strict
|
15
|
+
next if result.ok?(@config.strict)
|
16
16
|
@failures[test_case.location.file] ||= []
|
17
17
|
@failures[test_case.location.file] << test_case.location.line
|
18
18
|
end
|
@@ -19,7 +19,7 @@ module Cucumber
|
|
19
19
|
@issues = ConsoleIssues.new(@config)
|
20
20
|
@start_time = Time.now
|
21
21
|
|
22
|
-
@config.on_event :
|
22
|
+
@config.on_event :test_case_started do |event|
|
23
23
|
print_feature event.test_case
|
24
24
|
print_test_case event.test_case
|
25
25
|
end
|
data/lib/cucumber/glue/dsl.rb
CHANGED
@@ -86,36 +86,18 @@ module Cucumber
|
|
86
86
|
Dsl.register_rb_hook('after_step', tag_expressions, proc)
|
87
87
|
end
|
88
88
|
|
89
|
-
# Registers a proc that will be called with a step definition argument if it
|
90
|
-
# matches the pattern passed as the first argument to Transform. Alternatively, if
|
91
|
-
# the pattern contains captures then they will be yielded as arguments to the
|
92
|
-
# provided proc. The return value of the proc is consequently yielded to the
|
93
|
-
# step definition.
|
94
|
-
def Transform(regexp, &proc)
|
95
|
-
Cucumber.deprecate(
|
96
|
-
'Use ParameterType(...) instead',
|
97
|
-
'Transform',
|
98
|
-
'2.6.0'
|
99
|
-
)
|
100
|
-
parameter_type = CucumberExpressions::ParameterType.new(
|
101
|
-
regexp.to_s,
|
102
|
-
regexp,
|
103
|
-
Object,
|
104
|
-
proc,
|
105
|
-
false,
|
106
|
-
true
|
107
|
-
)
|
108
|
-
Dsl.define_parameter_type(parameter_type)
|
109
|
-
end
|
110
|
-
|
111
89
|
def ParameterType(options)
|
90
|
+
type = options[:type] || Object
|
91
|
+
use_for_snippets = true if options[:use_for_snippets].nil?
|
92
|
+
prefer_for_regexp_match = false if options[:prefer_for_regexp_match].nil?
|
93
|
+
|
112
94
|
parameter_type = CucumberExpressions::ParameterType.new(
|
113
95
|
options[:name],
|
114
96
|
options[:regexp],
|
115
|
-
|
97
|
+
type,
|
116
98
|
options[:transformer],
|
117
|
-
|
118
|
-
|
99
|
+
use_for_snippets,
|
100
|
+
prefer_for_regexp_match
|
119
101
|
)
|
120
102
|
Dsl.define_parameter_type(parameter_type)
|
121
103
|
end
|