7
7
![ License] ( https://img.shields.io/crates/l/assert_cli.svg )
8
8
[ ![ crates.io] ( https://img.shields.io/crates/v/assert_cli.svg )] [ Crates.io ]
9
9
10
- ## Install
10
+ Note: ` assert_cli ` , in its current form, is deprecated. The spiritual
11
+ successor to ` assert_cli ` is [ ` assert_cmd ` ] [ assert_cmd ] .
11
12
12
- For your tests, add it to your ` Cargo.toml ` :
13
-
14
- ``` toml
15
- [dev-dependencies ]
16
- assert_cli = " 0.6"
17
- ```
18
-
19
- ## Example
20
-
21
- Here's a trivial example:
22
-
23
- ``` rust,ignore
24
- extern crate assert_cli;
25
-
26
- fn main() {
27
- assert_cli::Assert::main_binary().unwrap();
28
- }
29
- ```
30
-
31
- And here is one that will fail (and demonstrates running arbitrary commands):
32
-
33
- ``` rust
34
- extern crate assert_cli;
35
-
36
- fn main () {
37
- assert_cli :: Assert :: command (& [" ls" , " foo-bar-foo" ])
38
- . fails ()
39
- . and ()
40
- . stderr (). contains (" foo-bar-foo" )
41
- . unwrap ();
42
- }
43
- ```
44
-
45
- If you want to match the program's output _ exactly_ , you can use
46
- ` stdout().is ` (and shows the macro form of ` command ` ):
47
-
48
- ``` rust,should_panic
49
- #[macro_use] extern crate assert_cli;
50
-
51
- fn main() {
52
- assert_cmd!(wc "README.md")
53
- .stdout().is("1337 README.md")
54
- .unwrap();
55
- }
56
- ```
57
-
58
- ... which has the benefit to show a nice, colorful diff in your terminal,
59
- like this:
60
-
61
- ``` diff
62
- - 1337
63
- + 92
64
- ```
65
-
66
- ** Tip** : Enclose arguments in the ` assert_cmd! ` macro in quotes ` " ` ,
67
- if there are special characters, which the macro doesn't accept, e.g.
68
- ` assert_cmd!(cat "foo.txt") ` .
69
-
70
- Assert Cli use [ Environment] [ Environment ] underneath to deal with environment variables.
71
-
72
- More detailed information is available in the [ documentation] . :-)
73
-
74
- ## Relevant crates
75
-
76
- Other crates that might be useful in testing command line programs.
77
- * [ dir-diff] [ dir-diff ] for testing file side-effects.
78
- * [ tempfile] [ tempfile ] for scratchpad directories.
79
- * [ duct] [ duct ] for orchestrating multiple processes.
13
+ Stayed tuned to [ Issue #41 ] [ future ] for our reinventing ` assert_cli ` on top of ` assert_cmd ` .
80
14
81
15
## License
82
16
@@ -97,7 +31,5 @@ conditions.
97
31
[ Travis ] : https://travis-ci.org/assert-rs/assert_cli
98
32
[ Crates.io ] : https://crates.io/crates/assert_cli
99
33
[ Documentation ] : https://docs.rs/assert_cli
100
- [ Environment ] : https://github.com/Freyskeyd/environment
101
- [ dir-diff ] : https://crates.io/crates/dir-diff
102
- [ tempfile ] : https://crates.io/crates/tempfile
103
- [ duct ] : https://crates.io/crates/duct
34
+ [ assert_cmd ] : https://crates.io/crates/assert_cmd
35
+ [ future ] : https://github.com/assert-rs/assert_cli/issues/41
0 commit comments