summaryrefslogtreecommitdiff
path: root/src/bindings.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-12-01 18:01:44 +0200
committerLars Wirzenius <liw@liw.fi>2023-12-25 10:17:07 +0200
commit9972ba7f7c798e12741e9310a258df64c9310c05 (patch)
tree0084856ea6a9c3dbb4c4cedac83d3b24aa48bdc0 /src/bindings.rs
parentd6ba90c694fe8905aadf02acbbb0ff7e24f30b4e (diff)
downloadsubplot-9972ba7f7c798e12741e9310a258df64c9310c05.tar.gz
feat: typeset scenarios by typesetting steps
Typeset each step in a scenario, including captures in the steps. Previously the scenario was just one <pre> element, now things can be styled with CSS. Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
Diffstat (limited to 'src/bindings.rs')
-rw-r--r--src/bindings.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/bindings.rs b/src/bindings.rs
index 380b0ed..b937edb 100644
--- a/src/bindings.rs
+++ b/src/bindings.rs
@@ -290,7 +290,8 @@ impl Binding {
// valid for this binding.
return None;
}
- PartialStep::text(name, cap)
+ let kind = self.types.get(name).unwrap_or(&CaptureType::Text);
+ PartialStep::text(name, cap, *kind)
}
};
@@ -318,7 +319,7 @@ impl Eq for Binding {}
#[cfg(test)]
mod test_binding {
- use super::Binding;
+ use super::{Binding, CaptureType};
use crate::html::Location;
use crate::PartialStep;
use crate::ScenarioStep;
@@ -401,7 +402,10 @@ mod test_binding {
assert_eq!(m.kind(), StepKind::Given);
let mut parts = m.parts();
assert_eq!(parts.next().unwrap(), &PartialStep::uncaptured("I am "));
- assert_eq!(parts.next().unwrap(), &PartialStep::text("who", "Tomjon"));
+ assert_eq!(
+ parts.next().unwrap(),
+ &PartialStep::text("who", "Tomjon", CaptureType::Text)
+ );
assert_eq!(parts.next().unwrap(), &PartialStep::uncaptured(", I am"));
assert_eq!(parts.next(), None);
}
@@ -608,6 +612,7 @@ fn from_hashmap(parsed: &ParsedBinding) -> Result<Binding, SubplotError> {
#[cfg(test)]
mod test_bindings {
+ use crate::bindings::CaptureType;
use crate::html::Location;
use crate::Binding;
use crate::Bindings;
@@ -808,9 +813,10 @@ mod test_bindings {
}
let p = parts.next().unwrap();
match p {
- PartialStep::CapturedText { name, text } => {
+ PartialStep::CapturedText { name, text, kind } => {
assert_eq!(name, "name");
assert_eq!(text, "Tomjon");
+ assert_eq!(kind, &CaptureType::Text);
}
_ => panic!("unexpected part: {:?}", p),
}