spec :: Spec
spec = do
  describe "loadConfig" $ do
    it "loads from kraken-web.conf by default" $ do
      withSystemTempDirectory "kraken-test" $ \ dir -> do
        withCurrentDirectory dir $ do
          let config = mkConfig 9832 "http://foo.com/bar"
          writeFile "kraken-web.conf" $ cs $ encode config
          withArgs [] loadConfig `shouldReturn` config

    it "loads from a file given by --config" $ do
      withSystemTempDirectory "kraken-test" $ \ dir -> do
        withCurrentDirectory dir $ do
          let config = mkConfig 8439 "http://bar.com/boo"
          writeFile "something.file" $ cs $ encode config
          withArgs (words "--config something.file") loadConfig
            `shouldReturn` config

  describe "kraken-web.conf.example" $ do
    it "can be parsed as a configuration file" $ do
      config <- withArgs (words "--config kraken-web.conf.example")
        loadConfig
      deepseq (encode config) (return ())
spec :: Spec
spec = do
  describe "loadConfig" $ do
    it "loads from kraken-web.conf by default" $ do
      withSystemTempDirectory "kraken-test" $ \ dir -> do
        withCurrentDirectory dir $ do
          let config = mkConfig 9832 "http://foo.com/bar"
          writeFile "kraken-web.conf" $ cs $ encode config
          withArgs [] loadConfig `shouldReturn` config

    it "loads from a file given by --config" $ do
      withSystemTempDirectory "kraken-test" $ \ dir -> do
        withCurrentDirectory dir $ do
          let config = mkConfig 8439 "http://bar.com/boo"
          writeFile "something.file" $ cs $ encode config
          withArgs (words "--config something.file") loadConfig
            `shouldReturn` config

  describe "kraken-web.conf.example" $ do
    it "can be parsed as a configuration file" $ do
      config <- withArgs (words "--config kraken-web.conf.example")
        loadConfig
      deepseq (encode config) (return ())
spec = do
  describe "loadConfig" $ do
    it "loads from kraken-web.conf by default" $ do
      withSystemTempDirectory "kraken-test" $ \ dir -> do
        withCurrentDirectory dir $ do
          let config = mkConfig 9832 "http://foo.com/bar"
          writeFile "kraken-web.conf" $ cs $ encode config
          withArgs [] loadConfig `shouldReturn` config

    it "loads from a file given by --config" $ do
      withSystemTempDirectory "kraken-test" $ \ dir -> do
        withCurrentDirectory dir $ do
          let config = mkConfig 8439 "http://bar.com/boo"
          writeFile "something.file" $ cs $ encode config
          withArgs (words "--config something.file") loadConfig
            `shouldReturn` config

  describe "kraken-web.conf.example" $ do
    it "can be parsed as a configuration file" $ do
      config <- withArgs (words "--config kraken-web.conf.example")
        loadConfig
      deepseq (encode config) (return ())