1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
//! Filesystem fixtures and assertions for testing.
//!
//! Fixtures:
//! - A sandbox to work within (see [`TempDir`]).
//! - Setup the sandbox (see [`FileTouch`], [`FileWriteBin`], [`FileWriteStr`], [`PathCopy`]).
//!
//! For assertions, see [`PathAssert`].
//!
//! ```toml
//! [dependencies]
//! assert_fs = "0.10"
//! ```
//!
//! ## Overview
//!
//! Setting up a fixture
//! - [`TempDir`]
//! - [`touch`][`FileTouch`] a [`ChildPath`]
//! - [`write_binary`][`FileWriteBin`] a [`ChildPath`]
//! - [`write_str`][`FileWriteStr`] a [`ChildPath`]
//! - [`copy_from`][`PathCopy`] a pristine folder to a [`ChildPath`] or [`TempDir`]
//!
//! Validating
//! - [`assert`][`PathAssert`] a [`ChildPath`] or [`TempDir`]
//!
//! ## Example
//!
//! Here is a trivial example:
//!
//! ```rust
//! extern crate assert_fs;
//! extern crate predicates;
//!
//! 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();
//! ```
//!
//! ## Relevant crates
//!
//! Other crates that might be useful in testing command line programs.
//!
//! [`TempDir`]: struct.TempDir.html
//! [`ChildPath`]: fixture/struct.ChildPath.html
//! [`FileTouch`]: fixture/trait.FileTouch.html
//! [`FileWriteBin`]: fixture/trait.FileWriteBin.html
//! [`FileWriteStr`]: fixture/trait.FileWriteStr.html
//! [`PathCopy`]: fixture/trait.PathCopy.html
//! [`PathAssert`]: assert/trait.PathAssert.html
//! [dir-diff]: https://crates.io/crates/dir-diff
#![warn(missing_docs)]
extern crate globwalk;
extern crate predicates;
extern crate predicates_core;
extern crate predicates_tree;
extern crate tempfile;
pub mod assert;
mod errors;
pub mod fixture;
// Pulling this in for convenience-sake
#[doc(inline)]
pub use fixture::TempDir;
/// Extension traits that are useful to have available.
pub mod prelude {
pub use assert::PathAssert;
pub use fixture::FileTouch;
pub use fixture::FileWriteBin;
pub use fixture::FileWriteStr;
pub use fixture::PathChild;
pub use fixture::PathCopy;
}