Skip to content

Commit c6767bd

Browse files
committed
Use the result type 'ambiguous' for ambiguous step matches.
Cucumber-Messages has a separate test step result status 'AMBIGUOUS', therefore cucumber-ruby should use the test result type 'ambiguous' for ambiguous step matches.
1 parent 50c3705 commit c6767bd

File tree

6 files changed

+12
-33
lines changed

6 files changed

+12
-33
lines changed

features/docs/defining_steps/ambiguous_steps.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ Feature: Ambiguous Steps
4040
features/step_definitions.rb:5:in `/^an ambiguous step$/'
4141
4242
You can run again with --guess to make Cucumber be more smart about it
43-
(Cucumber::Ambiguous)
43+
(Cucumber::Core::Test::Result::Ambiguous)
4444
features/ambiguous.feature:5:in `an ambiguous step'
4545
46-
Failing Scenarios:
46+
Ambiguous Scenarios:
4747
cucumber features/ambiguous.feature:3 # Scenario:
4848
49-
1 scenario (1 failed)
50-
2 steps (1 failed, 1 passed)
49+
1 scenario (1 ambiguous)
50+
2 steps (1 ambiguous, 1 passed)
5151
0m0.012s
5252
5353
"""

lib/cucumber/formatter/ansicolor.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ module Formatter
4747
# * <tt>flaky_param</tt> - defaults to <tt>yellow,bold</tt>
4848
# * <tt>failed</tt> - defaults to <tt>red</tt>
4949
# * <tt>failed_param</tt> - defaults to <tt>red,bold</tt>
50+
# * <tt>ambiguous</tt> - defaults to <tt>red</tt>
51+
# * <tt>abmiguous_param</tt> - defaults to <tt>red,bold</tt>
5052
# * <tt>passed</tt> - defaults to <tt>green</tt>
5153
# * <tt>passed_param</tt> - defaults to <tt>green,bold</tt>
5254
# * <tt>outline</tt> - defaults to <tt>cyan</tt>
@@ -72,6 +74,7 @@ module ANSIColor
7274
'pending' => 'yellow',
7375
'flaky' => 'yellow',
7476
'failed' => 'red',
77+
'ambiguous' => 'red',
7578
'passed' => 'green',
7679
'outline' => 'cyan',
7780
'skipped' => 'cyan',

lib/cucumber/formatter/duration_extractor.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def passed(*) end
1414

1515
def failed(*) end
1616

17+
def ambiguous(*) end
18+
1719
def undefined(*) end
1820

1921
def skipped(*) end

lib/cucumber/formatter/junit.rb

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def create_output_string(test_case, scenario, result, row_name)
131131
end
132132

133133
def build_testcase(result, scenario_designation, output)
134-
duration = ResultBuilder.new(result).test_case_duration
134+
duration = DurationExtractor.new(result).result_duration
135135
@current_feature_data[:time] += duration
136136
classname = @current_feature_data[:feature].name
137137
filename = @current_feature_data[:uri]
@@ -234,32 +234,5 @@ def examples_table_row(row)
234234
@name_suffix = " (outline example : #{@row_name})"
235235
end
236236
end
237-
238-
class ResultBuilder
239-
attr_reader :test_case_duration
240-
241-
def initialize(result)
242-
@test_case_duration = 0
243-
result.describe_to(self)
244-
end
245-
246-
def passed(*) end
247-
248-
def failed(*) end
249-
250-
def undefined(*) end
251-
252-
def skipped(*) end
253-
254-
def pending(*) end
255-
256-
def exception(*) end
257-
258-
def duration(duration, *)
259-
duration.tap { |dur| @test_case_duration = dur.nanoseconds / 10**9.0 }
260-
end
261-
262-
def attach(*) end
263-
end
264237
end
265238
end

lib/cucumber/formatter/progress.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def print_summary
9494
CHARS = {
9595
passed: '.',
9696
failed: 'F',
97+
ambiguous: 'A',
9798
undefined: 'U',
9899
pending: 'P',
99100
skipped: '-'

lib/cucumber/step_match.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def initialize(error)
148148
end
149149

150150
def activate(test_step)
151-
test_step.with_action { raise @error }
151+
test_step.with_action { raise Core::Test::Result::Ambiguous, @error.message }
152152
end
153153
end
154154
end

0 commit comments

Comments
 (0)