Created
May 18, 2017 09:06
-
-
Save caoilte/2e59d9e88c6deb77c4dfc29e9a84eaed to your computer and use it in GitHub Desktop.
unit testing HTTP4s encoders
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
package httpServices | |
import io.circe.Printer | |
import org.http4s.circe.CirceInstances | |
import org.scalatest.{FlatSpec, Matchers} | |
import io.circe.generic.auto._ | |
import org.http4s.dsl._ | |
class ExampleEncoderTest extends FlatSpec with Matchers { | |
case class TestObject(someValue: Int, someOptionalValue:Option[Int]) | |
object Encoders extends CirceInstances { | |
override protected def defaultPrinter: Printer = Printer.noSpaces.copy(dropNullKeys = true) | |
implicit val schedulesEncoder = jsonEncoderOf[TestObject] | |
} | |
it should "Test the Encoders Object concisely!" in { | |
import Encoders._ | |
Ok(TestObject(5, None)).as[String].unsafePerformSync shouldEqual | |
"""{"someValue":5}""" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment