diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cli.rs | 26 |
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(()) } |