summaryrefslogtreecommitdiff
path: root/src/steps.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-06-07 18:24:54 +0300
committerLars Wirzenius <liw@liw.fi>2023-06-07 18:24:54 +0300
commit21beb119ed2a8a1dcf1dfc8b6bd91d3ba46b10af (patch)
tree99cdb46451ea07079f279488f11783a794306055 /src/steps.rs
parentff61617ca720750cda810d16275485e973068af5 (diff)
downloadsubplot-21beb119ed2a8a1dcf1dfc8b6bd91d3ba46b10af.tar.gz
feat! don't allow indented scenario steps
Some day we will have syntax for continuing a step to the next line. This change makes it easier to introduce that syntax, without a breaking change. Sponsored-by: author
Diffstat (limited to 'src/steps.rs')
-rw-r--r--src/steps.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/steps.rs b/src/steps.rs
index b0a15e9..1005ad8 100644
--- a/src/steps.rs
+++ b/src/steps.rs
@@ -51,6 +51,10 @@ impl ScenarioStep {
text: &str,
default: Option<StepKind>,
) -> Result<ScenarioStep, SubplotError> {
+ if text.trim_start() != text {
+ return Err(SubplotError::NotAtBoln(text.into()));
+ }
+
let mut words = text.split_whitespace();
let keyword = match words.next() {
@@ -126,7 +130,7 @@ mod test {
#[test]
fn parses_given_with_extra_spaces() {
- let step = ScenarioStep::new_from_str(" given I am Tomjon ", None).unwrap();
+ let step = ScenarioStep::new_from_str("given I am Tomjon ", None).unwrap();
assert_eq!(step.kind(), StepKind::Given);
assert_eq!(step.text(), "I am Tomjon");
}