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

Commit

Permalink
Mark assert_cli as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 6, 2018
1 parent faeb524 commit 3e260e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 73 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ docmatic = "0.1"

[badges]
travis-ci = { repository = "assert-rs/assert_cli" }
maintenance = { status = "deprecated" }
78 changes: 5 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,10 @@
![License](https://img.shields.io/crates/l/assert_cli.svg)
[![crates.io](https://img.shields.io/crates/v/assert_cli.svg)][Crates.io]

## Install
Note: `assert_cli`, in its current form, is deprecated. The spiritual
successor to `assert_cli` is [`assert_cmd`][assert_cmd].

For your tests, add it to your `Cargo.toml`:

```toml
[dev-dependencies]
assert_cli = "0.6"
```

## Example

Here's a trivial example:

```rust,ignore
extern crate assert_cli;
fn main() {
assert_cli::Assert::main_binary().unwrap();
}
```

And here is one that will fail (and demonstrates running arbitrary commands):

```rust
extern crate assert_cli;

fn main() {
assert_cli::Assert::command(&["ls", "foo-bar-foo"])
.fails()
.and()
.stderr().contains("foo-bar-foo")
.unwrap();
}
```

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

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

... which has the benefit to show a nice, colorful diff in your terminal,
like this:

```diff
-1337
+92
```

**Tip**: Enclose arguments in the `assert_cmd!` macro in quotes `"`,
if there are special characters, which the macro doesn't accept, e.g.
`assert_cmd!(cat "foo.txt")`.

Assert Cli use [Environment][Environment] underneath to deal with environment variables.

More detailed information is available in the [documentation]. :-)

## Relevant crates

Other crates that might be useful in testing command line programs.
* [dir-diff][dir-diff] for testing file side-effects.
* [tempfile][tempfile] for scratchpad directories.
* [duct][duct] for orchestrating multiple processes.
Stayed tuned to [Issue #41][future] for our reinventing `assert_cli` on top of `assert_cmd`.

## License

Expand All @@ -97,7 +31,5 @@ conditions.
[Travis]: https://travis-ci.org/assert-rs/assert_cli
[Crates.io]: https://crates.io/crates/assert_cli
[Documentation]: https://docs.rs/assert_cli
[Environment]: https://github.com/Freyskeyd/environment
[dir-diff]: https://crates.io/crates/dir-diff
[tempfile]: https://crates.io/crates/tempfile
[duct]: https://crates.io/crates/duct
[assert_cmd]: https://crates.io/crates/assert_cmd
[future]: https://github.com/assert-rs/assert_cli/issues/41

0 comments on commit 3e260e7

Please sign in to comment.