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

Commit

Permalink
Change stdout/sterr asseertion API
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

- `.prints` -> `.stdout().contains`
- `.prints_exactly` -> `.stdout().is`
- `.prints_error` -> `.stderr().contains`
- `.prints_error_exactly` -> `.stderr().is`
  • Loading branch information
epage committed Sep 14, 2017
1 parent c25b46b commit 1f042ba
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 163 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Here's a trivial example:
extern crate assert_cli;

fn main() {
assert_cli::Assert::command(&["echo", "42"]).prints("42").unwrap();
assert_cli::Assert::command(&["echo", "42"]).stdout().contains("42").unwrap();
}
```

Expand All @@ -31,7 +31,7 @@ Or if you'd rather use the macro, to save you some writing:
#[macro_use] extern crate assert_cli;

fn main() {
assert_cmd!(echo "42").prints("42").unwrap();
assert_cmd!(echo "42").stdout().contains("42").unwrap();
}
```

Expand All @@ -45,21 +45,21 @@ fn main() {
let test = assert_cmd!(ls "foo-bar-foo")
.fails()
.and()
.prints_error("foo-bar-foo")
.stderr().contains("foo-bar-foo")
.execute();
assert!(test.is_ok());
}
```

If you want to match the program's output _exactly_, you can use
`prints_exactly`:
`stdout().is`:

```rust,should_panic
#[macro_use] extern crate assert_cli;
fn main() {
assert_cmd!(wc "README.md")
.prints_exactly("1337 README.md")
.stdout().is("1337 README.md")
.unwrap();
}
```
Expand Down
Loading

0 comments on commit 1f042ba

Please sign in to comment.