use anyhow::Context; use assert_cmd::prelude::*; use predicates::prelude::*; use tempfile::TempDir; use std::process::Command; #[test] fn help_prints_correctly() -> Result<(), anyhow::Error> { let tempdir = TempDir::new()?; let datadir = tempdir.path().to_str().context("Tempdir path was not valid utf8")?; Command::cargo_bin("aspm")? .env("ASPM_DATA_DIR", datadir) .arg("--help") .assert() .success() .stdout(predicate::str::starts_with(env!("CARGO_PKG_DESCRIPTION"))); Command::cargo_bin("aspm")? .env("ASPM_DATA_DIR", datadir) .arg("-h") .assert() .success() .stdout(predicate::str::starts_with(env!("CARGO_PKG_DESCRIPTION"))); Command::cargo_bin("aspm")? .env("ASPM_DATA_DIR", datadir) .assert() .code(2) .stderr(predicate::str::starts_with(env!("CARGO_PKG_DESCRIPTION"))); Ok(()) }