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

Commit 2cf0cf6

Browse files
committed
Add doc(test)s for returning Output
1 parent c22f859 commit 2cf0cf6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ assert_cli::assert_cli("echo", &["42"]).unwrap();
5757
assert_cli!("echo", &["42"] => Success).unwrap();
5858
```
5959

60+
All exported functions and the macro return a `Result` containing the
61+
`Output` of the process, allowing you to do further custom assertions:
62+
63+
```rust
64+
#[macro_use] extern crate assert_cli;
65+
let output = assert_cli!("echo", &["Number 42"] => Success).unwrap();
66+
let stdout = std::str::from_utf8(&output.stdout).unwrap();
67+
assert!(stdout.contains("42"));
68+
```
69+
6070
## License
6171

6272
Licensed under either of

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
//! # }
3636
//! ```
3737
//!
38+
//! All exported functions and the macro return a `Result` containing the
39+
//! `Output` of the process, allowing you to do further custom assertions:
40+
//!
41+
//! ```rust
42+
//! # #[macro_use] extern crate assert_cli;
43+
//! # fn main() {
44+
//! let output = assert_cli!("echo", &["Number 42"] => Success).unwrap();
45+
//! let stdout = std::str::from_utf8(&output.stdout).unwrap();
46+
//! assert!(stdout.contains("42"));
47+
//! # }
48+
//! ```
49+
//!
3850
//! Make sure to include the crate as `#[macro_use] extern crate assert_cli;`.
3951
4052

0 commit comments

Comments
 (0)