Expand description
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
.
[dependencies]
assert_fs = "0.10"
Overview
Setting up a fixture
TempDir
touch
aChildPath
write_binary
aChildPath
write_str
aChildPath
copy_from
a pristine folder to aChildPath
orTempDir
Validating
Example
Here is a trivial example:
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.
Modules
Filesystem assertions.
Initialize the filesystem to use as test fixtures.
Extension traits that are useful to have available.
Structs
A directory in the filesystem that is automatically deleted when
it goes out of scope.