Crate expectorate[−][src]
This library is for comparing multi-line output to data stored in version controlled files. It makes it easy to update the contents when should be updated to match the new results.
Use it like this:
let actual: &str = compose(); expectorate::assert_contents!("lyrics.txt", actual);
If the output doesn’t match, the program will panic! and emit the color-coded diffs.
To accept the changes from compose()
, run with ! EXPECTORATE=overwrite
.
Assuming lyrics.txt
is checked in, git diff
will show you something like
this:
diff --git a/examples/lyrics.txt b/examples/lyrics.txt
index e4104c1..ea6beaf 100644
--- a/examples/lyrics.txt
+++ b/examples/lyrics.txt
@@ -1,5 +1,2 @@
-No one hits like Gaston
-Matches wits like Gaston
-In a spitting match nobody spits like Gaston
+In a testing match nobody tests like Gaston
I'm especially good at expectorating
-Ten points for Gaston
Macros
assert_contents | Compare the contents of the file to the data provided |