Commit dde22027 by Gabriel Falcao

bug fix by @davidsulc: tags shouldn't be parsed as steps when using backgrounds. closes #336

parent 57ac2743
......@@ -492,8 +492,10 @@ class Step(object):
None,
invalid_first_line_error % (lines[0], 'multiline'))
# Select only lines that aren't end-to-end whitespace
lines = filter(lambda x: not REP.only_whitespace.match(x), lines)
# Select only lines that aren't end-to-end whitespace and aren't tags
# Tags could be inclueed as steps if the first scenario following a background is tagged
# This then causes the test to fail, because lettuce looks for the step's definition (which doesn't exist)
lines = filter(lambda x: not (REP.only_whitespace.match(x) or re.match(r'^\s*@', x)), lines)
step_strings = []
in_multiline = False
......
......@@ -23,6 +23,15 @@ I_HAVE_TASTY_BEVERAGES = """I have the following tasty beverages in my freezer:
""".strip()
I_DIE_HAPPY = "I shall die with love in my heart"
BACKGROUND_WITH_TAGGED_SCENARIO = '''
Background:
background line 1
@wip
Scenario:
Scenario line 1
'''
MULTI_LINE = '''
I have a string like so:
"""
......@@ -155,6 +164,12 @@ def test_can_parse_two_ordinary_steps():
assert_equals(steps[0].sentence, I_DIE_HAPPY)
assert_equals(steps[1].sentence, I_LIKE_VEGETABLES)
def test_can_parse_background_and_ignore_tag():
"It should correctly parse and ignore tags between the background and first step."
steps = Step.many_from_lines(BACKGROUND_WITH_TAGGED_SCENARIO.splitlines())
steps_without_tags = filter(lambda x: not x.sentence == '@wip', steps)
assert_equals(len(steps), len(steps_without_tags))
def test_cannot_start_with_multiline():
"It should raise an error when a step starts with a multiline string"
lines = strings.get_stripped_lines(INVALID_MULTI_LINE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment