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

Commit

Permalink
Add example constructor for Assert
Browse files Browse the repository at this point in the history
  • Loading branch information
volks73 committed May 21, 2018
1 parent a352d02 commit bbf0fd8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ impl Assert {
}
}

/// Run a specific example of the current crate.
///
/// Defaults to asserting _successful_ execution.
pub fn example<S: AsRef<OsStr>>(name: S) -> Self {
Assert {
cmd: vec![
OsStr::new("cargo"),
OsStr::new("run"),
#[cfg(not(debug_assertions))]
OsStr::new("--release"),
OsStr::new("--quiet"),
OsStr::new("--example"),
name.as_ref(),
OsStr::new("--"),
].into_iter()
.map(OsString::from)
.collect(),
..Self::default()
}
}

/// Run a custom command.
///
/// Defaults to asserting _successful_ execution.
Expand Down

0 comments on commit bbf0fd8

Please sign in to comment.