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

Add example constructor for Assert #108

Merged
merged 1 commit into from
May 21, 2018
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
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