@@ -57,22 +57,22 @@ use cli_error::CliError;
5757/// To test that
5858///
5959/// ```sh
60- /// ls -n1 src/
60+ /// bash -c $BLACK_BOX
6161/// ```
6262///
6363/// returns
6464///
6565/// ```plain
66- /// cli_error.rs
67- /// diff.rs
68- /// lib.rs
66+ /// Launch sequence initiated.
6967/// ```
7068///
7169/// you would call it like this:
7270///
73- /// ```rust,no_run
71+ /// ```rust
7472/// # extern crate assert_cli;
75- /// assert_cli::assert_cli_output("ls", &["-n1", "src/"], "cli_error.rs\ndiff.rs\nlib.rs");
73+ /// # const BLACK_BOX: &'static str = r#"function test_helper() {\
74+ /// # echo "Launch sequence initiated."; return 0; }; test_helper"#;
75+ /// assert_cli::assert_cli_output("bash", &["-c", BLACK_BOX], "Launch sequence initiated.");
7676/// ```
7777pub fn assert_cli_output < S > ( cmd : & str , args : & [ S ] , expected_output : & str ) -> Result < ( ) , Box < Error > >
7878 where S : AsRef < OsStr >
@@ -100,7 +100,28 @@ pub fn assert_cli_output<S>(cmd: &str, args: &[S], expected_output: &str) -> Res
100100 . map_err ( From :: from)
101101}
102102
103- /// Assert a CLI call fails with the expected error code and output.
103+ /// Assert a CLI call that fails the expected `stderr` output and error code.
104+ ///
105+ /// To test that
106+ ///
107+ /// ```sh
108+ /// bash -c $BLACK_BOX
109+ /// ```
110+ ///
111+ /// fails with an exit code of `42` after printing this to `stderr`
112+ ///
113+ /// ```plain
114+ /// error no 42!
115+ /// ```
116+ ///
117+ /// you would call it like this:
118+ ///
119+ /// ```rust
120+ /// # extern crate assert_cli;
121+ /// # const BLACK_BOX: &'static str = r#"function test_helper() {\
122+ /// # >&2 echo "error no 42!"; return 42; }; test_helper"#;
123+ /// assert_cli::assert_cli_output_error("bash", &["-c", BLACK_BOX], Some(42), "error no 42!");
124+ /// ```
104125pub fn assert_cli_output_error < S > ( cmd : & str ,
105126 args : & [ S ] ,
106127 error_code : Option < i32 > ,
0 commit comments