@@ -204,17 +204,29 @@ impl Assert {
204
204
///
205
205
/// # Examples
206
206
///
207
- /// ```rust
207
+ /// ```rust,ignore
208
208
/// use assert_cmd::prelude::*;
209
209
///
210
210
/// use std::process::Command;
211
+ /// use predicates::prelude::*;
212
+ ///
213
+ /// Command::main_binary()
214
+ /// .unwrap()
215
+ /// .env("exit", "42")
216
+ /// .assert()
217
+ /// .code(predicate::eq(42));
211
218
///
219
+ /// // which can be shortened to:
212
220
/// Command::main_binary()
213
221
/// .unwrap()
214
222
/// .env("exit", "42")
215
223
/// .assert()
216
224
/// .code(42);
217
225
/// ```
226
+ ///
227
+ /// See [`IntoCodePredicate`] for other built-in conversions.
228
+ ///
229
+ /// [IntoCodePredicate]: trait.IntoCodePredicate.html
218
230
pub fn code < I , P > ( self , pred : I ) -> Self
219
231
where
220
232
I : IntoCodePredicate < P > ,
@@ -241,18 +253,31 @@ impl Assert {
241
253
///
242
254
/// # Examples
243
255
///
244
- /// ```rust
256
+ /// ```rust,ignore
245
257
/// use assert_cmd::prelude::*;
246
258
///
247
259
/// use std::process::Command;
260
+ /// use predicates::prelude::*;
248
261
///
249
262
/// Command::main_binary()
250
263
/// .unwrap()
251
264
/// .env("stdout", "hello")
252
265
/// .env("stderr", "world")
253
266
/// .assert()
267
+ /// .stdout(predicate::str::similar("hello\n").from_utf8());
268
+ ///
269
+ /// // which can be shortened to:
270
+ /// Command::main_binary()
271
+ /// .unwrap()
272
+ /// .env("stdout", "hello")
273
+ /// .env("stderr", "world")
274
+ /// .assert()
254
275
/// .stdout("hello\n");
255
276
/// ```
277
+ ///
278
+ /// See [`IntoOutputPredicate`] for other built-in conversions.
279
+ ///
280
+ /// [IntoOutputPredicate]: trait.IntoOutputPredicate.html
256
281
pub fn stdout < I , P > ( self , pred : I ) -> Self
257
282
where
258
283
I : IntoOutputPredicate < P > ,
@@ -275,18 +300,31 @@ impl Assert {
275
300
///
276
301
/// # Examples
277
302
///
278
- /// ```rust
303
+ /// ```rust,ignore
279
304
/// use assert_cmd::prelude::*;
280
305
///
281
306
/// use std::process::Command;
307
+ /// use predicates::prelude::*;
282
308
///
283
309
/// Command::main_binary()
284
310
/// .unwrap()
285
311
/// .env("stdout", "hello")
286
312
/// .env("stderr", "world")
287
313
/// .assert()
314
+ /// .stderr(predicate::str::similar("world\n").from_utf8());
315
+ ///
316
+ /// // which can be shortened to:
317
+ /// Command::main_binary()
318
+ /// .unwrap()
319
+ /// .env("stdout", "hello")
320
+ /// .env("stderr", "world")
321
+ /// .assert()
288
322
/// .stderr("world\n");
289
323
/// ```
324
+ ///
325
+ /// See [`IntoOutputPredicate`] for other built-in conversions.
326
+ ///
327
+ /// [IntoOutputPredicate]: trait.IntoOutputPredicate.html
290
328
pub fn stderr < I , P > ( self , pred : I ) -> Self
291
329
where
292
330
I : IntoOutputPredicate < P > ,
@@ -332,18 +370,20 @@ impl fmt::Debug for Assert {
332
370
/// use assert_cmd::prelude::*;
333
371
///
334
372
/// use std::process::Command;
373
+ /// use predicates::prelude::*;
335
374
///
336
375
/// Command::main_binary()
337
376
/// .unwrap()
338
377
/// .env("exit", "42")
339
378
/// .assert()
340
- /// .code(42);
341
- /// // which is equivalent to
379
+ /// .code(predicate::eq(42));
380
+ ///
381
+ /// // which can be shortened to:
342
382
/// Command::main_binary()
343
383
/// .unwrap()
344
384
/// .env("exit", "42")
345
385
/// .assert()
346
- /// .code(predicates::ord::eq(42) );
386
+ /// .code(42 );
347
387
/// ```
348
388
///
349
389
/// [`Assert::code`]: struct.Assert.html#method.code
@@ -397,6 +437,30 @@ impl IntoCodePredicate<predicates::iter::InPredicate<i32>> for &'static [i32] {
397
437
/// Used by [`Assert::stdout`] and [`Assert::stderr`] to convert Self
398
438
/// into the needed [`Predicate<[u8]>`].
399
439
///
440
+ /// # Examples
441
+ ///
442
+ /// ```rust,ignore
443
+ /// use assert_cmd::prelude::*;
444
+ ///
445
+ /// use std::process::Command;
446
+ /// use predicates::prelude::*;
447
+ ///
448
+ /// Command::main_binary()
449
+ /// .unwrap()
450
+ /// .env("stdout", "hello")
451
+ /// .env("stderr", "world")
452
+ /// .assert()
453
+ /// .stdout(predicate::str::similar("hello\n").from_utf8());
454
+ ///
455
+ /// // which can be shortened to:
456
+ /// Command::main_binary()
457
+ /// .unwrap()
458
+ /// .env("stdout", "hello")
459
+ /// .env("stderr", "world")
460
+ /// .assert()
461
+ /// .stdout("hello\n");
462
+ /// ```
463
+ ///
400
464
/// [`Assert::stdout`]: struct.Assert.html#method.stdout
401
465
/// [`Assert::stderr`]: struct.Assert.html#method.stderr
402
466
/// [`Predicate<[u8]>`]: https://docs.rs/predicates-core/0.9.0/predicates_core/trait.Predicate.html
0 commit comments