import org.specs2.mutable._
import play.api.libs.json._
import reactivemongo.bson.BSONObjectID

import models.Task
import models.Task._

class TaskSpec extends Specification {

  val task = Task(Some(BSONObjectID.generate), "I'm new")

  "JSON serialization" should {
    "round trip validation and parse of JSON to recreate serialized object" in {
      Json.toJson(task).validate[Task].get must be equalTo task
    }

    "should serialize to JSON" in {
      Json.obj("id" -> task.id.get.stringify, "label" -> task.label) must be_==(Json.toJson(task))
    }
  }
}

import models.Task
import models.Task._
import org.specs2.mutable._
import play.api.libs.json._
import reactivemongo.bson.BSONObjectID

class TaskSpec extends Specification {

  "JSON serialization" should {
    "should serialize to JSON" in {
      val id = Some(BSONObjectID.generate)
      val expectedJson = Json.obj("id" -> id.get.stringify, "label" -> "I'm new")
      Json.toJson(Task(id, "I'm new")) must be equalTo expectedJson
    }

    "round trip validation and parse of JSON to recreate serialized object" in {
      val task = Task(Some(BSONObjectID.generate), "I'm new")
      Json.toJson(task).validate[Task].get must be equalTo task
    }
  }
}

Clean up Task JSON serialization spec.
Clean up Task JSON serialization spec.
