From 0a6b2b259862b90ccca11281de89091e2e01cb4d Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 24 Nov 2012 10:56:19 +0100 Subject: Add snapshots --- tests/Hakyll/Core/Runtime/Tests.hs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'tests/Hakyll/Core/Runtime') diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs index bb39a5f..0d202c7 100644 --- a/tests/Hakyll/Core/Runtime/Tests.hs +++ b/tests/Hakyll/Core/Runtime/Tests.hs @@ -6,17 +6,14 @@ module Hakyll.Core.Runtime.Tests -------------------------------------------------------------------------------- -import System.FilePath (()) -import Test.Framework (Test, testGroup) -import Test.HUnit (Assertion, (@?=)) +import System.FilePath (()) +import Test.Framework (Test, testGroup) +import Test.HUnit (Assertion, (@?=)) -------------------------------------------------------------------------------- -import Hakyll.Core.Configuration -import Hakyll.Core.Routes -import Hakyll.Core.Rules +import Hakyll import Hakyll.Core.Runtime -import Hakyll.Web.Page import TestSuite.Util @@ -31,7 +28,18 @@ case01 = withTestConfiguration $ \config -> do _ <- run config $ do match "*.md" $ do route $ setExtension "html" - compile $ pageCompiler + compile $ do + body <- getResourceBody + saveSnapshot "raw" body + return $ renderPandoc body - out <- readFile $ destinationDirectory config "example.html" - lines out @?= ["

This is an example.

"] + match "bodies.txt" $ route idRoute + create "bodies.txt" $ do + items <- requireAllSnapshots "*.md" "raw" :: Compiler [Item String] + makeItem $ concat $ map itemBody items + + example <- readFile $ destinationDirectory config "example.html" + lines example @?= ["

This is an example.

"] + + bodies <- readFile $ destinationDirectory config "bodies.txt" + head (lines bodies) @?= "This is an example." -- cgit v1.2.3