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

Commit 4cc32a5

Browse files
committed
Merge #38
38: Reuse output assertions between stdout/stderr r=killercup a=epage Reusing output assertions makes it easier to add new ones in the future. I feel the new naming scheme this provides makes intent of the API clearer as well (`stdout().contains` vs `prints`). This is done by creating an `OutputAssertionBuilder` that `Assertion` delegates to for creating output assertions, passing in an enum of which stream to read from. This unfortunately meant dropping the cool type tricks that were introduced in #24. This also required merging the storage of stdout/stderr assertions. To accommodate this, output assertions are now appended which might be useful on its own.
2 parents 0618fd2 + 64c766b commit 4cc32a5

File tree

5 files changed

+162
-212
lines changed

5 files changed

+162
-212
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Here's a trivial example:
2121
extern crate assert_cli;
2222

2323
fn main() {
24-
assert_cli::Assert::command(&["echo", "42"]).prints("42").unwrap();
24+
assert_cli::Assert::command(&["echo", "42"]).stdout().contains("42").unwrap();
2525
}
2626
```
2727

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

3333
fn main() {
34-
assert_cmd!(echo "42").prints("42").unwrap();
34+
assert_cmd!(echo "42").stdout().contains("42").unwrap();
3535
}
3636
```
3737

@@ -45,21 +45,21 @@ fn main() {
4545
let test = assert_cmd!(ls "foo-bar-foo")
4646
.fails()
4747
.and()
48-
.prints_error("foo-bar-foo")
48+
.stderr().contains("foo-bar-foo")
4949
.execute();
5050
assert!(test.is_ok());
5151
}
5252
```
5353

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

5757
```rust,should_panic
5858
#[macro_use] extern crate assert_cli;
5959
6060
fn main() {
6161
assert_cmd!(wc "README.md")
62-
.prints_exactly("1337 README.md")
62+
.stdout().is("1337 README.md")
6363
.unwrap();
6464
}
6565
```

0 commit comments

Comments
 (0)