Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
lettuce
Commits
71042be7
Commit
71042be7
authored
Jan 22, 2014
by
Ricky Cook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc, test and fix to parse outline substitutions in multiline strings
parent
c38ce400
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
docs/tutorial/scenario-outlines.rst
+7
-0
lettuce/core.py
+3
-0
tests/unit/test_scenario_parsing.py
+23
-0
No files found.
docs/tutorial/scenario-outlines.rst
View file @
71042be7
...
...
@@ -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
lettuce/core.py
View file @
71042be7
...
...
@@ -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
...
...
tests/unit/test_scenario_parsing.py
View file @
71042be7
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment