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
//! Filesystem fixtures and assertions for testing.
//!
//! `assert_fs` aims to simplify
//! - Setting up files for your tests to consume
//! - Asserting on files produced by your tests
//!
//! ```toml
//! [dependencies]
//! assert_fs = "1.0.0"
//! ```
//!
//! ## Overview
//!
//! Setting up a fixture
//! - [`TempDir`] or [`NamedTempFile`] for a sandbox to test in.
//! - [`touch`][`FileTouch`] a [`ChildPath`] or [`NamedTempFile`]
//! - [`write_binary`][`FileWriteBin`] a [`ChildPath`] or [`NamedTempFile`]
//! - [`write_str`][`FileWriteStr`] a [`ChildPath`] or [`NamedTempFile`]
//! - [`write_file`][`FileWriteFile`] a [`ChildPath`] or [`NamedTempFile`]
//! - [`copy_from`][`PathCopy`] a pristine folder to a [`ChildPath`] or [`TempDir`]
//!
//! Validating
//! - [`assert`][`PathAssert`] a [`ChildPath`], [`TempDir`], or [`NamedTempFile`]
//!
//! ## Example
//!
//! Here is a trivial example:
//!
//! ```rust
//! 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();
//! ```
//!
//! [`TempDir`]: struct.TempDir.html
//! [`NamedTempFile`]: struct.NamedTempFile.html
//! [`ChildPath`]: fixture/struct.ChildPath.html
//! [`FileTouch`]: fixture/trait.FileTouch.html
//! [`FileWriteBin`]: fixture/trait.FileWriteBin.html
//! [`FileWriteStr`]: fixture/trait.FileWriteStr.html
//! [`FileWriteFile`]: fixture/trait.FileWriteFile.html
//! [`PathCopy`]: fixture/trait.PathCopy.html
//! [`PathAssert`]: assert/trait.PathAssert.html
//! [dir-diff]: https://crates.io/crates/dir-diff

#![warn(missing_docs)]

pub mod assert;
pub mod fixture;

// Pulling this in for convenience-sake
#[doc(inline)]
pub use crate::fixture::TempDir;

// Pulling this in for convenience-sake
#[doc(inline)]
pub use crate::fixture::NamedTempFile;

/// Extension traits that are useful to have available.
pub mod prelude {
    pub use crate::assert::PathAssert;
    pub use crate::fixture::FileTouch;
    pub use crate::fixture::FileWriteBin;
    pub use crate::fixture::FileWriteFile;
    pub use crate::fixture::FileWriteStr;
    pub use crate::fixture::PathChild;
    pub use crate::fixture::PathCopy;
    pub use crate::fixture::PathCreateDir;
}

#[macro_use]
extern crate doc_comment;
doctest!("../README.md");