Skip to content

Commit

Permalink
Disallow whitespace in std tag names
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Sep 2, 2019
1 parent 198cce4 commit c0f9d6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/radish/parser/grammer.g
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tag: std_tag | precondition_tag
// A standard gherkin Tag in the form of:
// * @tag
// * @tag with whitespace
std_tag: "@" STRING_NO_TAG_NL _NEWLINE?
std_tag: "@" STRING_NO_WS _NEWLINE?

// A radish Precondition Tag in the form of:
// * @precondition(feature: scenario)
Expand Down Expand Up @@ -96,7 +96,6 @@ BUT: "But "i
// terminals used to match things
TEXTLINE.0: /.*\n/
STRING_NO_TAG_NL.0: /[^\n@]/+
STRING_NO_COLON_NL.0: /[^\n:]/+
STRING_NO_PAREN_NL.0: /[^\n\)\(]/+
STRING_NO_NL.0: /[^\n]/+
Expand Down
22 changes: 2 additions & 20 deletions tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,6 @@ def test_parse_tag_from_a_feature(parser):
assert ast.tags[0].name == "tag-a"


def test_parse_tag_with_spaces_from_a_feature(parser):
"""The parser should parse a Tag containing spaces from a Feature"""
# given
feature_file = """
@tag - a
Feature: My Feature
"""

# when
ast = parser.parse_contents(None, feature_file)

# then
assert len(ast.tags) == 1
assert ast.tags[0].name == "tag - a"


def test_parse_tags_on_multiple_lines_from_a_feature(parser):
"""The parser should parse multiple Tags on multiple lines from a Feature"""
# given
Expand All @@ -212,19 +196,17 @@ def test_parse_tags_on_same_line_from_a_feature(parser):
"""The parser should parse multiple Tags on the same line from a Feature"""
# given
feature_file = """
@tag-a @tag-b @tag - c @tag-d
@tag-a @tag-b
Feature: My Feature
"""

# when
ast = parser.parse_contents(None, feature_file)

# then
assert len(ast.tags) == 4
assert len(ast.tags) == 2
assert ast.tags[0].name == "tag-a"
assert ast.tags[1].name == "tag-b"
assert ast.tags[2].name == "tag - c"
assert ast.tags[3].name == "tag-d"


def test_parse_tags_on_multiple_and_same_line_from_a_feature(parser):
Expand Down

0 comments on commit c0f9d6a

Please sign in to comment.