summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2016-05-27 16:00:00 -0400
committerDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2018-09-26 18:11:11 -0400
commita1a17acb326020f1b57f587230cb439e901784df (patch)
tree358a1ea916a242609a981ff46e2a6814a2208cec /tests
parentf1a294e5ddb8ae0ccdcef1a12561e603ff996cfe (diff)
Ported to Debian jessie
Most of the churn here comes from rebasing the Yesod boilerplate.
Diffstat (limited to 'tests')
-rw-r--r--tests/HomeTest.hs36
-rw-r--r--tests/TestImport.hs13
-rw-r--r--tests/main.hs17
3 files changed, 42 insertions, 24 deletions
diff --git a/tests/HomeTest.hs b/tests/HomeTest.hs
index 17c9e6d..25a23b1 100644
--- a/tests/HomeTest.hs
+++ b/tests/HomeTest.hs
@@ -1,24 +1,28 @@
+{-# LANGUAGE OverloadedStrings #-}
module HomeTest
( homeSpecs
) where
-import Import
-import Yesod.Test
+import TestImport
-homeSpecs :: Specs
+homeSpecs :: Spec
homeSpecs =
- describe "These are some example tests" $
- it "loads the index and checks it looks right" $ do
- get_ "/"
- statusIs 200
- htmlAllContain "h1" "Hello"
+ ydescribe "These are some example tests" $ do
- post "/" $ do
- addNonce
- fileByLabel "Choose a file" "tests/main.hs" "text/plain" -- talk about self-reference
- byLabel "What's on the file?" "Some Content"
+ yit "loads the index and checks it looks right" $ do
+ get HomeR
+ statusIs 200
+ htmlAllContain "h1" "Hello"
- statusIs 200
- htmlCount ".message" 1
- htmlAllContain ".message" "Some Content"
- htmlAllContain ".message" "text/plain"
+ request $ do
+ setMethod "POST"
+ setUrl HomeR
+ addNonce
+ fileByLabel "Choose a file" "tests/main.hs" "text/plain" -- talk about self-reference
+ byLabel "What's on the file?" "Some Content"
+
+ statusIs 200
+ printBody
+ htmlCount ".message" 1
+ htmlAllContain ".message" "Some Content"
+ htmlAllContain ".message" "text/plain"
diff --git a/tests/TestImport.hs b/tests/TestImport.hs
new file mode 100644
index 0000000..04249f9
--- /dev/null
+++ b/tests/TestImport.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE OverloadedStrings #-}
+module TestImport
+ ( module Yesod.Test
+ , module Foundation
+ , Spec
+ , Example
+ ) where
+
+import Yesod.Test
+import Foundation
+
+type Spec = YesodSpec App
+type Example = YesodExample App
diff --git a/tests/main.hs b/tests/main.hs
index d475fe8..a869b66 100644
--- a/tests/main.hs
+++ b/tests/main.hs
@@ -5,18 +5,19 @@
module Main where
import Import
-import Settings
-import Yesod.Logger (defaultDevelopmentLogger)
import Yesod.Default.Config
import Yesod.Test
+import Test.Hspec (hspec)
import Application (makeFoundation)
import HomeTest
-main :: IO a
+main :: IO ()
main = do
- conf <- loadConfig $ (configSettings Testing) { csParseExtra = parseExtra }
- logger <- defaultDevelopmentLogger
- foundation <- makeFoundation conf logger
- app <- toWaiAppPlain foundation
- runTests app (connPool foundation) homeSpecs
+ conf <- Yesod.Default.Config.loadConfig $ (configSettings Testing)
+ { csParseExtra = parseExtra
+ }
+ foundation <- makeFoundation conf
+ hspec $ do
+ yesodSpec foundation $ do
+ homeSpecs