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

Commit a01f933

Browse files
authored
Merge pull request #56 from dsprenkels/ignore_status
Add Assert::ignore_status() for ignoring the command status
2 parents d1aa8ec + 95be0f1 commit a01f933

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/assert.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,30 @@ impl Assert {
238238
self
239239
}
240240

241+
/// Do not care whether the command exits successfully or if it fails.
242+
///
243+
/// This function removes any assertions that were already set, including
244+
/// any expected exit code that was set with [`fails_with`].
245+
///
246+
/// # Examples
247+
///
248+
/// ```rust
249+
/// extern crate assert_cli;
250+
///
251+
/// assert_cli::Assert::command(&["cat", "non-existing-file"])
252+
/// .ignore_status()
253+
/// .and()
254+
/// .stderr().is("cat: non-existing-file: No such file or directory")
255+
/// .unwrap();
256+
/// ```
257+
///
258+
/// [`fails_with`]: #method.fails_with
259+
pub fn ignore_status(mut self) -> Self {
260+
self.expect_exit_code = None;
261+
self.expect_success = None;
262+
self
263+
}
264+
241265
/// Create an assertion for stdout's contents
242266
///
243267
/// # Examples

0 commit comments

Comments
 (0)