Commit 71042be7 by Ricky Cook

Doc, test and fix to parse outline substitutions in multiline strings

parent c38ce400
......@@ -44,4 +44,11 @@ reducing "copy & paste" work and making your tests more clear.
step [e], you'll see your description expanding to the five
previous scenarios:
.. Note::
When using XML, your tags may have the same name as an outline substitution.
If you need to call an outline substitution variable a similar name (eg
```<head>```), maybe think about calling it something like ```<_head>```
instead.
.. image:: ./screenshot7.png
......@@ -263,6 +263,7 @@ class Step(object):
def solve_and_clone(self, data, display_step):
sentence = self.sentence
multiline = self.multiline
hashes = self.hashes[:] # deep copy
for k, v in data.items():
......@@ -276,10 +277,12 @@ class Step(object):
return new_row
sentence = evaluate(sentence)
multiline = evaluate(multiline)
hashes = map(evaluate_hash_value, hashes)
new = deepcopy(self)
new.sentence = sentence
new.multiline = multiline
new.hashes = hashes
new.display = display_step
return new
......
......@@ -64,6 +64,19 @@ Examples:
| 2 | 4 |
"""
OUTLINED_SCENARIO_WITH_SUBSTITUTIONS_IN_MULTILINE = '''
Scenario Outline: Parsing HTML
When I parse the HTML:
"""
<div><v></div>
"""
I should see "outline value"
Examples:
| v |
| outline value |
'''
OUTLINED_FEATURE = """
Feature: Do many things at once
In order to automate tests
......@@ -326,6 +339,16 @@ def test_scenario_tables_are_solved_against_outlines():
assert_equals(type(step), Step)
assert_equals(step.hashes, expected_hashes)
def test_scenario_tables_are_solved_against_outlines():
"Outline substitution should apply to multiline strings within a scenario"
expected_multiline = '<div>outline value</div>'
scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_SUBSTITUTIONS_IN_MULTILINE)
step = scenario.solved_steps[0]
assert_equals(type(step), Step)
assert_equals(step.multiline, expected_multiline)
def test_solved_steps_also_have_scenario_as_attribute():
"Steps solved in scenario outlines also have scenario as attribute"
scenario = Scenario.from_string(OUTLINED_SCENARIO)
......
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