summaryrefslogtreecommitdiff
path: root/tests/cli.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-02-21 11:46:09 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-02-21 11:47:08 +0200
commitff6025a26312dd2e098fb2d6e3920eecffdad217 (patch)
tree97bf5bcaef1c6cc44aae0feb0cde78b35a0034e5 /tests/cli.rs
parent0d4e33ca99f104336e93acd0bb9a5a06b427e5d8 (diff)
Prompt in a loop
Diffstat (limited to 'tests/cli.rs')
-rw-r--r--tests/cli.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 18d815e..a4d368f 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -1,7 +1,25 @@
-use assert_cmd::Command;
+use assert_cmd::cargo::cargo_bin;
+use rexpect::{session::PtySession, spawn};
+use std::error::Error;
+
+fn spawn_interactive_process() -> Result<PtySession, Box<dyn Error>> {
+ let path = cargo_bin(env!("CARGO_PKG_NAME"));
+ let process = spawn(&path.display().to_string(), Some(3000))?;
+ Ok(process)
+}
+
+#[test]
+fn shows_a_prompt() -> Result<(), Box<dyn Error>> {
+ let mut p = spawn_interactive_process()?;
+ p.exp_string("> ")?;
+ Ok(())
+}
#[test]
-fn shows_a_prompt() {
- let mut cmd = Command::cargo_bin("shackle").unwrap();
- cmd.assert().success().stdout(">");
+fn does_nothing_after_receiving_whitespace_input() -> Result<(), Box<dyn Error>> {
+ let mut p = spawn_interactive_process()?;
+ p.exp_string("> ")?;
+ p.send_line("")?;
+ p.exp_string("> ")?;
+ Ok(())
}