From 0639d66b4d25eb71202caf64820bf00b47b06681 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 9 Feb 2020 18:27:34 +0200 Subject: Fix: use the right tag for scenario blocks We were using the "subplot" tag, when the correct tag is "scenario". Tests pass despite the change. --- subplot.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/subplot.md b/subplot.md index f7d38ac..ff05be7 100644 --- a/subplot.md +++ b/subplot.md @@ -488,7 +488,7 @@ functions: f.py # Simple This is the simplest possible test scenario -```subplot +```scenario given precondition foo when I do bar then bar was done @@ -579,7 +579,7 @@ functions: f.py ## heading 1.1 ### heading 1.1.1 -```subplot +```scenario given precondition foo ``` ~~~~ @@ -608,7 +608,7 @@ functions: f.py # heading 1 ## heading 1.1a -```subplot +```scenario given precondition foo ``` @@ -643,12 +643,12 @@ functions: f.py ## heading 1.1 ### heading 1.1.1 -```subplot +```scenario given precondition foo ``` ### heading 1.1.2 -```subplot +```scenario given precondition foo ``` ~~~~ @@ -680,12 +680,12 @@ functions: f.py ## heading 1.1 ### heading 1.1.1 -```subplot +```scenario given precondition foo ``` ## heading 1.2 -```subplot +```scenario given precondition foo ``` ~~~~ -- cgit v1.2.1 From 1b988f37fe96248ca412fc3159922636106e04f4 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 9 Feb 2020 18:29:57 +0200 Subject: Change: ignore empty lines in scenarios --- src/parser.rs | 10 +++++++++- subplot.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/parser.rs b/src/parser.rs index 39faab2..35cb488 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -4,7 +4,7 @@ /// Each logical line forms a scenario step. It may be divided into /// multiple physical lines. pub fn parse_scenario_snippet(snippet: &str) -> impl Iterator { - snippet.lines() + snippet.lines().filter(|line| !line.trim().is_empty()) } #[cfg(test)] @@ -32,4 +32,12 @@ mod test { vec!["given I am Tomjon", "when I declare myself king"] ) } + + #[test] + fn parses_two_lines_with_empty_line() { + assert_eq!( + parse_lines("given I am Tomjon\n\nwhen I declare myself king"), + vec!["given I am Tomjon", "when I declare myself king"] + ) + } } diff --git a/subplot.md b/subplot.md index ff05be7..7c72ea8 100644 --- a/subplot.md +++ b/subplot.md @@ -544,6 +544,51 @@ then program finished successfully ~~~ +Empty lines in scenarios +----------------------------------------------------------------------------- + +This scenario verifies that empty lines in scenarios are ignored. + +~~~scenario +given file emptylines.md +given file b.yaml +given file f.py +when I run sp-docgen emptylines.md -o emptylines.pdf +then file emptylines.pdf exists +when I run sp-docgen emptylines.md -o emptylines.html +then file emptylines.html exists +when I run sp-codegen --run emptylines.md -o test.py +then scenario "Simple" was run +then step "given precondition foo" was run +then step "when I do bar" was run +then step "then bar was done" was run +then program finished successfully +~~~ + + +### A document with a scenario with empty lines (emptylines.md) + +~~~~{.file #emptylines.md .markdown .numberLines} +--- +title: Test scenario +bindings: b.yaml +functions: f.py +... + +# Simple +This is the simplest possible test scenario + +```scenario +given precondition foo + +when I do bar + +then bar was done + +``` +~~~~ + + Document structure ----------------------------------------------------------------------------- -- cgit v1.2.1