Struct assert_cli::Assert [] [src]

pub struct Assert { /* fields omitted */ }

Assertions for a specific command

Methods

impl Assert
[src]

Use the crate's main binary as command

Use the crate's main binary as command

Use custom command

Examples

extern crate assert_cli;

assert_cli::Assert::command(&["echo", "1337"])
    .succeeds()
    .unwrap();

Add arguments to the command

Examples

extern crate assert_cli;

assert_cli::Assert::command(&["echo"])
    .with_args(&["42"])
    .succeeds()
    .prints("42")
    .unwrap();

Small helper to make chains more readable

Examples

extern crate assert_cli;

assert_cli::Assert::command(&["echo", "42"])
    .succeeds().and().prints("42")
    .unwrap();

Expect the command to be executed successfully

Examples

extern crate assert_cli;

assert_cli::Assert::command(&["echo", "42"])
    .succeeds()
    .unwrap();

Expect the command to fail

Examples

extern crate assert_cli;

assert_cli::Assert::command(&["cat", "non-exisiting-file"])
    .fails()
    .unwrap();

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();

Expect the command's output to contain output

Examples

extern crate assert_cli;

assert_cli::Assert::command(&["echo", "42"])
    .prints("42")
    .unwrap();

Expect the command to output exactly this output

Examples

extern crate assert_cli;

assert_cli::Assert::command(&["echo", "42"])
    .prints_exactly("42")
    .unwrap();

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();

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();

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());

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]

Formats the value using the given formatter.

impl Default for Assert
[src]

Construct an assert using cargo run -- as command.