This repository was archived by the owner on Dec 29, 2021. It is now read-only.
Commit 063b3ce
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 063b3ce
7 files changed
+262
-241
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
0 commit comments