Struct snapbox::cmd::OutputAssert
source · [−]pub struct OutputAssert { /* private fields */ }
Expand description
Assert the state of a Command
’s Output
.
Create an OutputAssert
through the Command::assert
.
Implementations
sourceimpl OutputAssert
impl OutputAssert
sourcepub fn with_assert(self, config: Assert) -> Self
pub fn with_assert(self, config: Assert) -> Self
Customize the assertion behavior
sourcepub fn get_output(&self) -> &Output
pub fn get_output(&self) -> &Output
Access the contained Output
.
sourcepub fn success(self) -> Self
pub fn success(self) -> Self
Ensure the command succeeded.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.assert()
.success();
sourcepub fn failure(self) -> Self
pub fn failure(self) -> Self
Ensure the command failed.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("exit", "1")
.assert()
.failure();
sourcepub fn interrupted(self) -> Self
pub fn interrupted(self) -> Self
Ensure the command aborted before returning a code.
sourcepub fn code(self, expected: i32) -> Self
pub fn code(self, expected: i32) -> Self
Ensure the command returned the expected code.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("exit", "42")
.assert()
.code(42);
sourcepub fn stdout_eq(self, expected: impl Into<Data>) -> Self
pub fn stdout_eq(self, expected: impl Into<Data>) -> Self
Ensure the command wrote the expected data to stdout
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stdout_eq("hello");
sourcepub fn stdout_eq_path(self, expected_path: impl AsRef<Path>) -> Self
pub fn stdout_eq_path(self, expected_path: impl AsRef<Path>) -> Self
Ensure the command wrote the expected data to stdout
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stdout_eq_path("tests/snapshots/output.txt");
sourcepub fn stdout_matches(self, expected: impl Into<Data>) -> Self
pub fn stdout_matches(self, expected: impl Into<Data>) -> Self
Ensure the command wrote the expected data to stdout
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stdout_matches("he[..]o");
sourcepub fn stdout_matches_path(self, expected_path: impl AsRef<Path>) -> Self
pub fn stdout_matches_path(self, expected_path: impl AsRef<Path>) -> Self
Ensure the command wrote the expected data to stdout
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stdout_matches_path("tests/snapshots/output.txt");
sourcepub fn stderr_eq(self, expected: impl Into<Data>) -> Self
pub fn stderr_eq(self, expected: impl Into<Data>) -> Self
Ensure the command wrote the expected data to stderr
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stderr_eq("world");
sourcepub fn stderr_eq_path(self, expected_path: impl AsRef<Path>) -> Self
pub fn stderr_eq_path(self, expected_path: impl AsRef<Path>) -> Self
Ensure the command wrote the expected data to stderr
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stderr_eq_path("tests/snapshots/err.txt");
sourcepub fn stderr_matches(self, expected: impl Into<Data>) -> Self
pub fn stderr_matches(self, expected: impl Into<Data>) -> Self
Ensure the command wrote the expected data to stderr
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stderr_matches("wo[..]d");
sourcepub fn stderr_matches_path(self, expected_path: impl AsRef<Path>) -> Self
pub fn stderr_matches_path(self, expected_path: impl AsRef<Path>) -> Self
Ensure the command wrote the expected data to stderr
.
use snapbox::cmd::Command;
use snapbox::cmd::cargo_bin;
let assert = Command::new(cargo_bin("snap_fixture"))
.env("stdout", "hello")
.env("stderr", "world")
.assert()
.stderr_matches_path("tests/snapshots/err.txt");
Auto Trait Implementations
impl RefUnwindSafe for OutputAssert
impl Send for OutputAssert
impl Sync for OutputAssert
impl Unpin for OutputAssert
impl UnwindSafe for OutputAssert
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more