Last active
February 3, 2026 20:23
-
-
Save dacr/76e4bd8b42d4605b418cc3b341a8fcfd to your computer and use it in GitHub Desktop.
Configuration using Typesafe Config / published by https://github.com/dacr/code-examples-manager #2218d7d4-698b-4601-b3b0-4ce774e52d5c/3e73586cb3ae445c26708e75c965e94309aec13c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // summary : Configuration using Typesafe Config | |
| // keywords : config, typesafe, @testable | |
| // publish : gist | |
| // authors : David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 2218d7d4-698b-4601-b3b0-4ce774e52d5c | |
| // created-on : 2021-12-22T11:51:23+01:00 | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // run-with : scala-cli $file | |
| // --------------------- | |
| //> using scala "3.4.2" | |
| //> using dep "org.scalatest::scalatest:3.2.16" | |
| //> using dep "com.typesafe:config:1.4.1" | |
| //> using objectWrapper | |
| // --------------------- | |
| import org.scalatest.*, flatspec.*, matchers.* | |
| import com.typesafe.config.* | |
| class ThatSpec extends AnyFlatSpec with should.Matchers { | |
| override def suiteName = "ThatSpec" | |
| "typesafe config" should "be able to manage boolean values but take care" in { | |
| val config = ConfigFactory.parseString( | |
| """param-a: true | |
| |param-b: True | |
| |""".stripMargin | |
| ) | |
| config.getBoolean("param-a") shouldBe true | |
| intercept[ConfigException.WrongType] { | |
| info("True | False are not booleans from typesafe config point of view, they are strings !") | |
| config.getBoolean("param-b") | |
| } | |
| config.getString("param-a").toBoolean shouldBe true | |
| config.getString("param-b").toBoolean shouldBe true | |
| } | |
| } | |
| org.scalatest.tools.Runner.main(Array("-oDF", "-s", classOf[ThatSpec].getName)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment