macro_rules! assert_matches_snapshot {
    ($to_snap:expr) => { ... };
    ($to_snap:expr, $description:expr) => { ... };
}
Expand description

Same as snapshot!() macro, but it takes a string as the only argument and stores the snapshot in a separate file instead of inlining it in the source code of the test.

#[test]
fn my_test() {
    struct A {
        name: &'a str,
        age: u32
    }

    let a = A { name: "Lance", age: 9 };

    // When first run with `K9_UPDATE_SNAPSHOTS=1` it will
    // create `__k9_snapshots__/my_test_file/my_test.snap` file
    // with contents being the serialized value of `a`.
    // Next time the test is run, if the newly serialized value of a
    // is different from the value of that snapshot file, the assertion
    // will fail.
    assert_matches_snapshot!(a);
}