| 1 |
@issue |
| 2 |
Feature: Issue #127: Strip trailing colons |
| 3 |
|
| 4 |
. Trailing colon in a step is stripped by the Gherkin parser. |
| 5 |
. Undefined step snippets should not suggest the step with a trailing colon. |
| 6 |
. |
| 7 |
. GENERAL RULE (by looking at the parser): |
| 8 |
. 1. Colon in step in feature file is OK |
| 9 |
. (parser strips this for step-with-table or step-with-multiline-text). |
| 10 |
. 2. Step definitions in Python files should not end with a colon |
| 11 |
. (used in @given/@when/@then decorators). |
| 12 |
|
| 13 |
|
| 14 |
Background: |
| 15 |
Given a new working directory |
| 16 |
And a file named "features/example127.feature" with: |
| 17 |
""" |
| 18 |
Feature: |
| 19 |
Scenario: |
| 20 |
Given the following superusers exist: |
| 21 |
| Name | User Id | |
| 22 |
| Alice | 101 | |
| 23 |
| Bob | 102 | |
| 24 |
""" |
| 25 |
|
| 26 |
Scenario: Step Definition has no trailing colon (GOOD CASE) |
| 27 |
Given a file named "features/steps/good_steps.py" with: |
| 28 |
""" |
| 29 |
from behave import given |
| 30 |
|
| 31 |
@given(u'the following superusers exist') |
| 32 |
def step_given_following_superusers_exist(context): |
| 33 |
pass |
| 34 |
""" |
| 35 |
When I run "behave -f plain features/example127.feature" |
| 36 |
Then it should pass |
| 37 |
And the command output should not contain: |
| 38 |
""" |
| 39 |
You can implement step definitions for undefined steps with these snippets: |
| 40 |
|
| 41 |
@given(u'the following superusers exist:') |
| 42 |
def step_impl(context): |
| 43 |
raise NotImplementedError(u'STEP: Given the following superusers exist:') |
| 44 |
""" |
| 45 |
|
| 46 |
Scenario: Step Definition has trailing colon (BAD CASE) |
| 47 |
Given a file named "features/steps/bad_steps.py" with: |
| 48 |
""" |
| 49 |
from behave import given |
| 50 |
|
| 51 |
@given(u'the following superusers exist:') |
| 52 |
def step_given_following_superusers_exist(context): |
| 53 |
pass |
| 54 |
""" |
| 55 |
When I run "behave -f plain features/example127.feature" |
| 56 |
Then it should fail |
| 57 |
And the command output should contain: |
| 58 |
""" |
| 59 |
You can implement step definitions for undefined steps with these snippets: |
| 60 |
|
| 61 |
@given(u'the following superusers exist') |
| 62 |
def step_impl(context): |
| 63 |
raise NotImplementedError(u'STEP: Given the following superusers exist') |
| 64 |
""" |