From 8b7c95e02f8dcd71482ce7d7a310225855e17ce4 Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sun, 9 Jul 2017 17:45:04 +0800 Subject: [PATCH] Made sure the rendered content actually contains the original text --- tests/integration_tests.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 8bd2751c..07a6dcf8 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -160,6 +160,28 @@ fn rendered_code_has_playpen_stuff() { assert_contains_strings(book_js, &[".playpen"]); } +#[test] +fn chapter_content_appears_in_rendered_document() { + let content = vec![ + ("index.html", "Here's some interesting text"), + ("second.html", "Second Chapter"), + ("first/nested.html", "testable code"), + ("first/index.html", "more text"), + ("conclusion.html", "Conclusion"), + ]; + + let temp = create_book(true); + let mut md = MDBook::new(temp.path()); + md.build().unwrap(); + + let destination = temp.path().join("book"); + + for (filename, text) in content { + let path = destination.join(filename); + assert_contains_strings(path, &[text]); + } +} + /// Create a dummy book in a temporary directory, using the contents of /// `SUMMARY_MD` as a guide. /// @@ -208,6 +230,8 @@ fn create_book(passing_test: bool) -> TempDir { temp } +/// Read the contents of the provided file into memory and then iterate through +/// the list of strings asserting that the file contains all of them. fn assert_contains_strings>(filename: P, strings: &[&str]) { println!("Checking {}", filename.as_ref().display()); println!(); @@ -226,4 +250,4 @@ fn assert_contains_strings>(filename: P, strings: &[&str]) { println!("Checking for {:?}", s); assert!(content.contains(s)); } -} \ No newline at end of file +}