json-spec-elm 0.3.0.2 → 0.3.0.3
raw patch · 2 files changed
+27/−18 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- json-spec-elm.cabal +1/−1
- test/test.hs +26/−17
json-spec-elm.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: json-spec-elm-version: 0.3.0.2+version: 0.3.0.3 synopsis: Elm code generate for `json-spec`. description: Produce elm types, encoders, and decoders from a
test/test.hs view
@@ -27,6 +27,7 @@ import qualified Data.Text as Text import qualified Data.Text.IO as TIO + main :: IO () main = hspec $ do@@ -173,6 +174,7 @@ TIO.hPutStrLn stderr (fromMaybe "" (HM.lookup ["Api", "Data"] actual)) TIO.hPutStrLn stderr "\n\n==========================================\n\n" actual `shouldBe` expected+ compileElm actual it "works with the example schema" $ let actual :: HashMap Module Text@@ -183,23 +185,7 @@ $ elmDefs (Proxy @ExampleSpec) in do- traverse_ writeModule (HM.toList actual)- callCommand "(cd elm-test; elm-format src/ --yes)"- callCommand- "(\- \cd elm-test; \- \yes Y | (\- \elm init; \- \elm install rtfeldman/elm-iso8601-date-strings; \- \elm install elm/json; \- \elm install elm/url; \- \elm install elm/time; \- \elm install elm/http\- \); \- \elm make src/Api/Data.elm\- \)"- callCommand "rm -rf elm-test"-+ compileElm actual it "works with nullable values" $ let actual :: HashMap Module Text@@ -243,8 +229,29 @@ TIO.hPutStrLn stderr (fromMaybe "" (HM.lookup ["Api", "Data"] actual)) TIO.hPutStrLn stderr "\n\n==========================================\n\n" actual `shouldBe` expected+ compileElm actual +compileElm :: HashMap Module Text -> IO ()+compileElm code = do+ traverse_ writeModule (HM.toList code)+ callCommand "(cd elm-test; elm-format src/ --yes)"+ callCommand+ "(\+ \cd elm-test; \+ \yes Y | (\+ \elm init; \+ \elm install rtfeldman/elm-iso8601-date-strings; \+ \elm install elm/json; \+ \elm install elm/url; \+ \elm install elm/time; \+ \elm install elm/http\+ \); \+ \elm make src/Api/Data.elm\+ \)"+ callCommand "rm -rf elm-test"++ {- This spec is copied from an as-yet uncompleted personal project. I just used it because it is fairly complex. Probably something known@@ -355,9 +362,11 @@ ] ) + type NullableSpec = Named "NullableInt" (JsonNullable JsonInt)+ writeModule :: (Module, Text) -> IO () writeModule (module_, content) = do