forked from cucumber/cucumber-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ambiguous_steps.feature
86 lines (65 loc) · 1.9 KB
/
ambiguous_steps.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Feature: Ambiguous Steps
When Cucumber searches for a step definition for a step, it might find multiple step
definitions that could match. In that case, it will give you an error that the step
definitions are ambiguous.
You can also use a `--guess` mode, where it uses magic powers to try and figure
out which of those two step definitions is most likely to be the one you meant it
to use. Use it with caution!
@wip
Scenario: Ambiguous steps
Given a file named "features/ambiguous.feature" with:
"""
Feature:
Scenario:
When a step
Then an ambiguous step
"""
And a file named "features/step_definitions.rb" with:
"""
When(/^a.*step$/) do
'foo'
end
Then(/^an ambiguous step$/) do
'bar'
end
"""
When I run `cucumber`
Then it should fail with:
"""
Ambiguous match of "an ambiguous step":
features/step_definitions.rb:1:in `/^a.*step$/'
features/step_definitions.rb:5:in `/^an ambiguous step$/'
You can run again with --guess to make Cucumber be more smart about it
(Cucumber::Ambiguous)
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
0m0.012s
"""
Scenario: Ambiguous steps with guess mode
Given a file named "features/ambiguous.feature" with:
"""
Feature:
Scenario:
When a step
Then an ambiguous step
"""
And a file named "features/step_definitions.rb" with:
"""
When(/^a.*step$/) do
'foo'
end
Then(/^an ambiguous step$/) do
'bar'
end
"""
When I run `cucumber -g`
Then it should pass with exactly:
"""
Feature:
Scenario: # features/ambiguous.feature:3
When a step # features/step_definitions.rb:1
Then an ambiguous step # features/step_definitions.rb:5
1 scenario (1 passed)
2 steps (2 passed)
0m0.012s
"""