Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #28 from pdolega/feature/downgrade-json4s-native
Browse files Browse the repository at this point in the history
Downgrading dependency to solve issue with conflicting json4s-core versions
  • Loading branch information
eed3si9n authored May 20, 2017
2 parents 39b9641 + e13d647 commit ef49eaa
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
.idea
9 changes: 6 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val dispatchVersion = SettingKey[String]("dispatchVersion")
lazy val unusedWarnings = Seq("-Ywarn-unused-import", "-Ywarn-unused")

lazy val commonSettings: Seq[Setting[_]] = Seq(
version in ThisBuild := "0.5.0-SNAPSHOT",
version in ThisBuild := "0.6.0",
organization in ThisBuild := "org.foundweekends",
homepage in ThisBuild := Some(url(s"https://github.com/sbt/${name.value}/#readme")),
licenses in ThisBuild := Seq("MIT" ->
Expand Down Expand Up @@ -38,10 +38,13 @@ lazy val root = (project in file("."))
description := "your packages, delivered fresh",
dispatchVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) => "0.11.3"
case Some((2, 10)) => "0.11.2"
case _ => "0.12.0"
}
},
libraryDependencies ++= Seq("net.databinder.dispatch" %% "dispatch-json4s-native" % dispatchVersion.value),
libraryDependencies ++= Seq(
"net.databinder.dispatch" %% "dispatch-json4s-native" % dispatchVersion.value,
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
),
initialCommands := "import scala.concurrent.ExecutionContext.Implicits.global;"
)
56 changes: 56 additions & 0 deletions src/test/scala/JsonVersionLibSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import org.json4s.JsonDSL._
import org.json4s.native.JsonMethods
import org.scalatest.{MustMatchers, WordSpec}

class JsonVersionLibSpec extends WordSpec with MustMatchers {

val jsonMethods = new JsonMethods {}

"Stringifying json" should {
println(s"Scala version tested is: ${scala.util.Properties.versionString}")

"should work all values" in {

val rendered = jsonMethods.compact(
jsonMethods.render(
("name" -> "randomName") ~
("desc" -> Option("basicDescription")) ~
("licenses" -> List("Apache", "MIT")) ~
("labels" -> List("label1", "label2")) ~
("vcs_url" -> Option("vcs"))
)
)

rendered must be(
"{" +
""""name":"randomName",""" +
""""desc":"basicDescription",""" +
""""licenses":["Apache","MIT"],""" +
""""labels":["label1","label2"],""" +
""""vcs_url":"vcs"""" +
"}"
)
}

"should work with some values omitted" in {

val rendered = jsonMethods.compact(
jsonMethods.render(
("name" -> "randomName") ~
("desc" -> (None : Option[String])) ~
("licenses" -> List[String]()) ~
("labels" -> List[String]()) ~
("vcs_url" -> (None : Option[String]))
)
)

rendered must be(
"{" +
""""name":"randomName",""" +
""""licenses":[],""" +
""""labels":[]""" +
"}"
)
}
}
}

0 comments on commit ef49eaa

Please sign in to comment.