From 4de8e968b78916ec4835a2c6bbea0440c732e016 Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Tue, 17 Oct 2017 11:59:26 +0200 Subject: [PATCH 1/2] Implement Assert::ignore_status Fixes #23 --- src/assert.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/assert.rs b/src/assert.rs index 74e45c0..c6cffbb 100644 --- a/src/assert.rs +++ b/src/assert.rs @@ -238,6 +238,25 @@ impl Assert { self } + /// Do not care whether the command exits successfully or if it fails. + /// + /// # Examples + /// + /// ```rust + /// extern crate assert_cli; + /// + /// assert_cli::Assert::command(&["cat", "non-existing-file"]) + /// .ignore_status() + /// .and() + /// .stderr().is("cat: non-existing-file: No such file or directory") + /// .unwrap(); + /// ``` + pub fn ignore_status(mut self) -> Self { + self.expect_exit_code = None; + self.expect_success = None; + self + } + /// Create an assertion for stdout's contents /// /// # Examples From 95be0f1de1ad94d74dcb739012c3e7c84338107c Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Tue, 17 Oct 2017 16:53:09 +0200 Subject: [PATCH 2/2] Add note to ignore_status about existing asserts Namely, it removes any assertions that were previously made. --- src/assert.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/assert.rs b/src/assert.rs index c6cffbb..b950d4b 100644 --- a/src/assert.rs +++ b/src/assert.rs @@ -240,6 +240,9 @@ impl Assert { /// Do not care whether the command exits successfully or if it fails. /// + /// This function removes any assertions that were already set, including + /// any expected exit code that was set with [`fails_with`]. + /// /// # Examples /// /// ```rust @@ -251,6 +254,8 @@ impl Assert { /// .stderr().is("cat: non-existing-file: No such file or directory") /// .unwrap(); /// ``` + /// + /// [`fails_with`]: #method.fails_with pub fn ignore_status(mut self) -> Self { self.expect_exit_code = None; self.expect_success = None;