Struct assert_cli::Assert
[−]
[src]
pub struct Assert { /* fields omitted */ }
Assertions for a specific command
Methods
impl Assert
[src]
fn main_binary() -> Self
Use the crate's main binary as command
fn cargo_binary(name: &str) -> Self
Use the crate's main binary as command
fn command(cmd: &[&str]) -> Self
Use custom command
Examples
extern crate assert_cli; assert_cli::Assert::command(&["echo", "1337"]) .succeeds() .unwrap();
fn with_args(self, args: &[&str]) -> Self
Add arguments to the command
Examples
extern crate assert_cli; assert_cli::Assert::command(&["echo"]) .with_args(&["42"]) .succeeds() .prints("42") .unwrap();
fn and(self) -> Self
Small helper to make chains more readable
Examples
extern crate assert_cli; assert_cli::Assert::command(&["echo", "42"]) .succeeds().and().prints("42") .unwrap();
fn succeeds(self) -> Self
Expect the command to be executed successfully
Examples
extern crate assert_cli; assert_cli::Assert::command(&["echo", "42"]) .succeeds() .unwrap();
fn fails(self) -> Self
Expect the command to fail
Examples
extern crate assert_cli; assert_cli::Assert::command(&["cat", "non-exisiting-file"]) .fails() .unwrap();
fn fails_with(self, expect_exit_code: i32) -> Self
Expect the command to fail and return a specific error code
Examples
extern crate assert_cli; assert_cli::Assert::command(&["cat", "non-exisiting-file"]) .fails_with(1) .unwrap();
fn prints<O: Into<String>>(self, output: O) -> Self
Expect the command's output to contain output
Examples
extern crate assert_cli; assert_cli::Assert::command(&["echo", "42"]) .prints("42") .unwrap();
fn prints_exactly<O: Into<String>>(self, output: O) -> Self
Expect the command to output exactly this output
Examples
extern crate assert_cli; assert_cli::Assert::command(&["echo", "42"]) .prints_exactly("42") .unwrap();
fn prints_error<O: Into<String>>(self, output: O) -> Self
Expect the command's stderr output to contain output
Examples
extern crate assert_cli; assert_cli::Assert::command(&["cat", "non-exisiting-file"]) .fails() .prints_error("non-exisiting-file") .unwrap();
fn prints_error_exactly<O: Into<String>>(self, output: O) -> Self
Expect the command to output exactly this output
to stderr
Examples
extern crate assert_cli; assert_cli::Assert::command(&["cat", "non-exisiting-file"]) .fails() .prints_error_exactly("cat: non-exisiting-file: No such file or directory") .unwrap();
fn execute(self) -> Result<(), Error>
Execute the command and check the assertions
Examples
extern crate assert_cli; let test = assert_cli::Assert::command(&["echo", "42"]) .succeeds() .execute(); assert!(test.is_ok());
fn unwrap(self)
Execute the command, check the assertions, and panic when they fail
Examples
extern crate assert_cli; assert_cli::Assert::command(&["echo", "42"]) .fails() .unwrap(); // panics
Trait Implementations
impl Debug for Assert
[src]
impl Default for Assert
[src]
fn default() -> Self
Construct an assert using cargo run --
as command.