Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,33 @@ impl AssertError {
fn panic<T>(self) -> T {
panic!("{}", self)
}

/// Returns the [`Assert`] wrapped into the [`Result`] produced by
/// the `try_` variants of the [`Assert`] methods.
///
/// # Examples
///
/// ```rust,no_run
/// use assert_cmd::prelude::*;
///
/// use std::process::Command;
/// use predicates::prelude::*;
///
/// let result = Command::new("echo")
/// .assert();
///
/// match result.try_success() {
/// Ok(assert) => {
/// assert.stdout(predicate::eq(b"Success\n" as &[u8]));
/// }
/// Err(err) => {
/// err.assert().stdout(predicate::eq(b"Err but some specific output you might want to check\n" as &[u8]));
/// }
/// }
/// ```
pub fn assert(self) -> Assert {
self.assert
}
}

impl Error for AssertError {}
Expand Down