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

Commit 3afd1e6

Browse files
committed
fix(output): Re-work API to work with rustfmt
rustfmt will split long builers across lines, even when that breaks logical grouping. For example ```rust assert_cli::Assert::command(&["ls", "foo-bar-foo"]) .fails() .and() .stderr().contains("foo-bar-foo") .unwrap(); ``` will be turned into ```rust assert_cli::Assert::command(&["ls", "foo-bar-foo"]) .fails() .and() .stderr() .contains("foo-bar-foo") .unwrap(); ``` which obscures intent. Normally, I don't like working around tools but this one seems sufficient to do so. ```rust assert_cli::Assert::command(&["ls", "foo-bar-foo"]) .fails() .and() .stderr(assert_cli::Output::contains("foo-bar-foo")) .unwrap(); ``` Pros - More consistent with `with_env` - Can add support for accepting arrays - Still auto-complete / docs friendly - Still expandable to additional assertions without much duplication or losing out on good error reporting Cons - More verbose if you don't `use assert_cli::{Assert, Environment, Output}` Alternatives - Accept distinct predicates - e.g. `.stderr(assert_cli::Is::text("foo-bar-foo"))` - e.g. `.stderr(assert_cli::Is::not("foo-bar-foo"))` - Strange `text` function - More structs to `use` - Less auto-complete / docs friendly (lacks contextual discovery or whatever the UX term is) Fixes #70 BREAKING CHANGE: `.stdout().contains(text)` is now `.stdout(assert_cli::Output::contains(text)`, etc.
1 parent 3bc9787 commit 3afd1e6

File tree

7 files changed

+262
-241
lines changed

7 files changed

+262
-241
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ fn main() {
3737
assert_cli::Assert::command(&["ls", "foo-bar-foo"])
3838
.fails()
3939
.and()
40-
.stderr().contains("foo-bar-foo")
40+
.stderr(assert_cli::Output::contains("foo-bar-foo"))
4141
.unwrap();
4242
}
4343
```
4444

4545
If you want to match the program's output _exactly_, you can use
46-
`stdout().is` (and shows the macro form of `command`):
46+
`Output::is` (and shows the macro form of `command`):
4747

4848
```rust,should_panic
4949
#[macro_use] extern crate assert_cli;
5050
5151
fn main() {
5252
assert_cmd!(wc "README.md")
53-
.stdout().is("1337 README.md")
53+
.stdout(assert_cli::Output::is("1337 README.md"))
5454
.unwrap();
5555
}
5656
```

0 commit comments

Comments
 (0)