[][src]Trait assert_fs::assert::PathAssert

pub trait PathAssert {
    fn assert<I, P>(&self, pred: I) -> &Self
    where
        I: IntoPathPredicate<P>,
        P: Predicate<Path>
; }

Assert the state of files within TempDir.

This uses IntoPathPredicate to provide short-hands for common cases, accepting:

  • Predicate<Path> for validating a path.
  • Predicate<str> for validating the content of the file.
  • &Path which must have the same file content.
  • &[u8] or &str representing the content of the file.

See predicates for more predicates.

Examples

use assert_fs::prelude::*;
use predicates::prelude::*;

let temp = assert_fs::TempDir::new().unwrap();
let input_file = temp.child("foo.txt");
input_file.touch().unwrap();

// ... do something with input_file ...

input_file.assert("");
temp.child("bar.txt").assert(predicate::path::missing());

temp.close().unwrap();

Required methods

fn assert<I, P>(&self, pred: I) -> &Self where
    I: IntoPathPredicate<P>,
    P: Predicate<Path>, 

Assert the state of files within TempDir.

This uses IntoPathPredicate to provide short-hands for common cases, accepting:

  • Predicate<Path> for validating a path.
  • Predicate<str> for validating the content of the file.
  • &Path which must have the same file content.
  • &[u8] or &str representing the content of the file.

See predicates for more predicates.

Examples

use assert_fs::prelude::*;
use predicates::prelude::*;

let temp = assert_fs::TempDir::new().unwrap();
let input_file = temp.child("foo.txt");
input_file.touch().unwrap();

// ... do something with input_file ...

input_file.assert("");
// or
input_file.assert(predicate::str::is_empty());

temp.child("bar.txt").assert(predicate::path::missing());

temp.close().unwrap();
Loading content...

Implementors

impl PathAssert for ChildPath[src]

impl PathAssert for NamedTempFile[src]

impl PathAssert for TempDir[src]

Loading content...