diff --git a/src/main/scala/net/ceedubs/ficus/readers/ChronoUnitReader.scala b/src/main/scala/net/ceedubs/ficus/readers/ChronoUnitReader.scala index 90eaa15..347719a 100644 --- a/src/main/scala/net/ceedubs/ficus/readers/ChronoUnitReader.scala +++ b/src/main/scala/net/ceedubs/ficus/readers/ChronoUnitReader.scala @@ -9,7 +9,7 @@ trait ChronoUnitReader { /** Reads the value at the path `path` in the Config */ override def read(config: Config, path: String): ChronoUnit = - ChronoUnit.valueOf(config.getString(path).toUpperCase) + ChronoUnit.valueOf(config.getString(path).toUpperCase.replace('-', '_')) } } diff --git a/src/test/scala/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala index 0230c67..87a43e3 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala @@ -35,4 +35,15 @@ class ChronoUnitReaderSpec extends Spec { chronoUnit should_== expected } + def readChronoUnitHalfDaysDash = { + val cfg = ConfigFactory.parseString(s""" + | foo { + | chrono-unit = "half-days" + | } + """.stripMargin) + val chronoUnit = cfg.as[ChronoUnit]("foo.chrono-unit") + val expected = ChronoUnit.HALF_DAYS + chronoUnit should_== expected + } + }