Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

Commit

Permalink
Document new output assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 22, 2017
1 parent 1f042ba commit 64c766b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,12 @@ impl Assert {
}
}

/// Assertions for command output.
#[derive(Debug)]
pub struct OutputAssertionBuilder {
pub assertion: Assert,
pub kind: OutputKind,
pub expected_result: bool,
assertion: Assert,
kind: OutputKind,
expected_result: bool,
}

impl OutputAssertionBuilder {
Expand Down
20 changes: 17 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
//! # fn main() {
//! assert_cmd!(cat "non-existing-file")
//! .fails()
//! .and()
//! .stderr().contains("non-existing-file")
//! .unwrap();
//! # }
//! ```
Expand All @@ -78,10 +76,25 @@
//! - Use `fails_with` to assert a specific exit status.
//! - There is also a `succeeds` method, but this is already the implicit default
//! and can usually be omitted.
//! - We can inspect the output of **stderr** with `stderr().contains` and `stderr().is`.
//! - The `and` method has no effect, other than to make everything more readable.
//! Feel free to use it. :-)
//!
//! ## stdout / stderr
//!
//! You can add assertions on the content of **stdout** and **stderr**. They
//! can be mixed together or even multiple of one stream can be used.
//!
//! ```rust
//! # #[macro_use] extern crate assert_cli;
//! # fn main() {
//! assert_cmd!(echo "Hello world! The ansswer is 42.")
//! .stdout().contains("Hello world")
//! .stdout().contains("42")
//! .stderr().is("")
//! .unwrap();
//! # }
//! ```
//!
//! ## Assert CLI Crates
//!
//! If you are testing a Rust binary crate, you can start with
Expand Down Expand Up @@ -119,3 +132,4 @@ mod diff;

mod assert;
pub use assert::Assert;
pub use assert::OutputAssertionBuilder;

0 comments on commit 64c766b

Please sign in to comment.