@@ -1,10 +1,9 @@
1−{-# LANGUAGE QuasiQuotes #-}
1+{-# LANGUAGE OverloadedStrings #-}
22module Data.Yaml.IncludeSpec (main, spec) where
33
44import Test.Hspec
55import Data.List (isPrefixOf)
66import Data.Aeson
7−import Data.Aeson.QQ
87import Data.Yaml (ParseException(InvalidYaml))
98import Data.Yaml.Include
109import Text.Libyaml (YamlException(YamlException))
@@ -12,28 +11,33 @@ import Text.Libyaml (YamlException(YamlException))
1211main :: IO ()
1312main = hspec spec
1413
14+asInt :: Int -> Int
15+asInt = id
16+
1517spec :: Spec
1618spec = do
1719 describe "decodeFile" $ do
1820 it "supports includes" $ do
19− decodeFile "test/resources/foo.yaml" `shouldReturn` Just [aesonQQ|
20− {
21− foo: 23,
22− bar: {one: 1, two: 2},
23− baz: 42
24− }
25− |]
21+ decodeFile "test/resources/foo.yaml" `shouldReturn` Just (object
22+ [ "foo" .= asInt 23
23+ , "bar" .= object
24+ [ "one" .= asInt 1
25+ , "two" .= asInt 2
26+ ]
27+ , "baz" .= asInt 42
28+ ])
2629
2730 it "supports recursive includes" $ do
28− decodeFile "test/resources/baz.yaml" `shouldReturn` Just [aesonQQ|
29− {
30− foo: {
31− foo: 23,
32− bar: {one: 1, two: 2},
33− baz: 42
34− }
35− }
36− |]
31+ decodeFile "test/resources/baz.yaml" `shouldReturn` Just (object
32+ [ "foo" .= object
33+ [ "foo" .= asInt 23
34+ , "bar" .= object
35+ [ "one" .= asInt 1
36+ , "two" .= asInt 2
37+ ]
38+ , "baz" .= asInt 42
39+ ]
40+ ])
3741
3842 it "aborts on cyclic includes" $ do
3943 (decodeFile "test/resources/loop/foo.yaml" :: IO (Maybe Value)) `shouldThrow` anyException