summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Hakyll/Core/Rules/Tests.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/Rules/Tests.hs b/tests/Hakyll/Core/Rules/Tests.hs
new file mode 100644
index 0000000..42b95fc
--- /dev/null
+++ b/tests/Hakyll/Core/Rules/Tests.hs
@@ -0,0 +1,41 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
+module Hakyll.Core.Rules.Tests
+ where
+
+import qualified Data.Map as M
+
+import Test.Framework
+
+import Hakyll.Core.Rules
+import Hakyll.Core.Identifier
+import Hakyll.Core.Routes
+import Hakyll.Core.Compiler
+import Hakyll.Core.Resource.Provider
+import Hakyll.Core.Resource.Provider.Dummy
+import Hakyll.Web.Page
+
+-- | Dummy resource provider
+--
+provider :: IO ResourceProvider
+provider = dummyResourceProvider $ M.fromList $ map (flip (,) "No content")
+ [ "posts/a-post.markdown"
+ , "posts/some-other-post.markdown"
+ ]
+
+-- | Example rules
+--
+rules :: Rules
+rules = do
+ -- Compile some posts
+ match "posts/*" $ do
+ route $ setExtension "html"
+ compile pageCompiler
+
+ -- Compile them, raw
+ group "raw" $ do
+ match "posts/*" $ do
+ route $ setExtension "html"
+ compile getResourceString
+
+ return ()