The example book renders correctly

This commit is contained in:
Michael Bryan 2017-12-04 15:38:57 +08:00
parent 751da4f05f
commit 12d1ed5558
No known key found for this signature in database
GPG Key ID: E9C602B0D9A998DC
2 changed files with 21 additions and 0 deletions

View File

@ -114,3 +114,13 @@ fn recursive_copy<A: AsRef<Path>, B: AsRef<Path>>(from: A, to: B) -> Result<()>
Ok(()) Ok(())
} }
pub fn new_copy_of_example_book() -> Result<TempDir> {
let temp = TempDir::new("book-example")?;
let book_example = Path::new(env!("CARGO_MANIFEST_DIR")).join("book-example");
recursive_copy(book_example, temp.path())?;
Ok(temp)
}

View File

@ -4,6 +4,7 @@ extern crate pretty_assertions;
extern crate select; extern crate select;
extern crate tempdir; extern crate tempdir;
extern crate walkdir; extern crate walkdir;
extern crate tempdir;
mod dummy_book; mod dummy_book;
@ -297,3 +298,13 @@ fn able_to_include_rust_files_in_chapters() {
]; ];
assert_contains_strings(second, playpen_strings); assert_contains_strings(second, playpen_strings);
} }
#[test]
fn example_book_can_build() {
let example_book_dir = dummy_book::new_copy_of_example_book().unwrap();
let mut md = MDBook::load(example_book_dir.path()).unwrap();
let got = md.build();
assert!(got.is_ok());
}