Created
April 4, 2009 08:33
-
-
Save sma/90151 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state = 0 | |
for line in lines: | |
if match(r"^\s*Scenario:\s*(.*)$", line): | |
current_scenario = new Scenario(match.r(1)) | |
current_feature.append_scenario(current_scenario) | |
state = 1 | |
if match(r"^\s*Given (.*)$", line): | |
if state != 1: raise Error("unexpected Given") | |
current_scenario.append_given_step(match.r(1).strip()) | |
if match(r"^\s*When (.*)$", line): | |
if state == 0: raise Error("unexpected When") | |
current_scenario.append_when_step(match.r(1).strip()) | |
state = 2 | |
if match(r"^\s*Then (.*)$", line): | |
if state == 0: raise Error("unexpected Then") | |
current_scenario.append_then_step(match.r(1).strip()) | |
state = 3 | |
if match(r"^\s*And (.*)$", line): | |
if state == 0: raise Error("unexpected And") | |
step = match.r(1).strip() | |
if state == 1: | |
current_scenario.append_given_step(step) | |
elif state == 2: | |
current_scenario.append_when_step(step) | |
elif state == 3: | |
current_scenario.append_then_step(step) | |
else: | |
raise Error() | |
if match(r"^\s*$", line): | |
state = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment